Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
douban-api-proxy
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
captainwong
douban-api-proxy
Commits
a371e40c
Commit
a371e40c
authored
Oct 20, 2019
by
Ozzieisaacs
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'github_3/hotfix/epub-import'
Improved cover extraction from epub files
parents
ccc61843
c7d7a759
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
45 additions
and
41 deletions
+45
-41
about.py
cps/about.py
+3
-2
converter.py
cps/converter.py
+3
-1
epub.py
cps/epub.py
+20
-13
stats.html
cps/templates/stats.html
+3
-3
messages.mo
cps/translations/de/LC_MESSAGES/messages.mo
+0
-0
messages.po
cps/translations/de/LC_MESSAGES/messages.po
+9
-15
uploader.py
cps/uploader.py
+7
-7
No files found.
cps/about.py
View file @
a371e40c
...
...
@@ -37,6 +37,7 @@ except ImportError:
from
flask_login.__about__
import
__version__
as
flask_loginVersion
try
:
import
unidecode
# _() necessary to make babel aware of string for translation
unidecode_version
=
_
(
u'installed'
)
except
ImportError
:
unidecode_version
=
_
(
u'not installed'
)
...
...
@@ -62,8 +63,8 @@ _VERSIONS = OrderedDict(
iso639
=
isoLanguages
.
__version__
,
pytz
=
pytz
.
__version__
,
Unidecode
=
unidecode_version
,
Flask_SimpleLDAP
=
_
(
u'installed'
)
if
bool
(
services
.
ldap
)
else
_
(
u'not installed'
)
,
Goodreads
=
_
(
u'installed'
)
if
bool
(
services
.
goodreads_support
)
else
_
(
u'not installed'
)
,
Flask_SimpleLDAP
=
u'installed'
if
bool
(
services
.
ldap
)
else
u'not installed'
,
Goodreads
=
u'installed'
if
bool
(
services
.
goodreads_support
)
else
u'not installed'
,
)
_VERSIONS
.
update
(
uploader
.
get_versions
())
...
...
cps/converter.py
View file @
a371e40c
...
...
@@ -19,6 +19,7 @@
from
__future__
import
division
,
print_function
,
unicode_literals
import
os
import
re
from
flask_babel
import
gettext
as
_
from
.
import
config
,
logger
from
.subproc_wrapper
import
process_wait
...
...
@@ -26,7 +27,8 @@ from .subproc_wrapper import process_wait
log
=
logger
.
create
()
_NOT_CONFIGURED
=
'not configured'
# _() necessary to make babel aware of string for translation
_NOT_CONFIGURED
=
_
(
'not configured'
)
_NOT_INSTALLED
=
'not installed'
_EXECUTION_ERROR
=
'Execution permissions missing'
...
...
cps/epub.py
View file @
a371e40c
...
...
@@ -64,7 +64,12 @@ def get_epub_info(tmp_file_path, original_file_name, original_file_extension):
for
s
in
[
'title'
,
'description'
,
'creator'
,
'language'
,
'subject'
]:
tmp
=
p
.
xpath
(
'dc:
%
s/text()'
%
s
,
namespaces
=
ns
)
if
len
(
tmp
)
>
0
:
epub_metadata
[
s
]
=
p
.
xpath
(
'dc:
%
s/text()'
%
s
,
namespaces
=
ns
)[
0
]
if
s
==
'creator'
:
epub_metadata
[
s
]
=
' & '
.
join
(
p
.
xpath
(
'dc:
%
s/text()'
%
s
,
namespaces
=
ns
))
elif
s
==
'subject'
:
epub_metadata
[
s
]
=
', '
.
join
(
p
.
xpath
(
'dc:
%
s/text()'
%
s
,
namespaces
=
ns
))
else
:
epub_metadata
[
s
]
=
p
.
xpath
(
'dc:
%
s/text()'
%
s
,
namespaces
=
ns
)[
0
]
else
:
epub_metadata
[
s
]
=
"Unknown"
...
...
@@ -109,18 +114,20 @@ def get_epub_info(tmp_file_path, original_file_name, original_file_extension):
meta_cover
=
tree
.
xpath
(
"/pkg:package/pkg:metadata/pkg:meta[@name='cover']/@content"
,
namespaces
=
ns
)
if
len
(
meta_cover
)
>
0
:
coversection
=
tree
.
xpath
(
"/pkg:package/pkg:manifest/pkg:item[@id='"
+
meta_cover
[
0
]
+
"']/@href"
,
namespaces
=
ns
)
if
len
(
coversection
)
>
0
:
filetype
=
coversection
[
0
]
.
rsplit
(
'.'
,
1
)[
-
1
]
if
filetype
==
"xhtml"
or
filetype
==
"html"
:
# if cover is (x)html format
markup
=
epubZip
.
read
(
os
.
path
.
join
(
coverpath
,
coversection
[
0
]))
markupTree
=
etree
.
fromstring
(
markup
)
# no matter xhtml or html with no namespace
imgsrc
=
markupTree
.
xpath
(
"//*[local-name() = 'img']/@src"
)
# imgsrc maybe startwith "../"" so fullpath join then relpath to cwd
filename
=
os
.
path
.
relpath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
join
(
coverpath
,
coversection
[
0
])),
imgsrc
[
0
]))
coverfile
=
extractCover
(
epubZip
,
filename
,
""
,
tmp_file_path
)
else
:
coverfile
=
extractCover
(
epubZip
,
coversection
[
0
],
coverpath
,
tmp_file_path
)
else
:
coversection
=
tree
.
xpath
(
"/pkg:package/pkg:guide/pkg:reference/@href"
,
namespaces
=
ns
)
if
len
(
coversection
)
>
0
:
filetype
=
coversection
[
0
]
.
rsplit
(
'.'
,
1
)[
-
1
]
if
filetype
==
"xhtml"
or
filetype
==
"html"
:
# if cover is (x)html format
markup
=
epubZip
.
read
(
os
.
path
.
join
(
coverpath
,
coversection
[
0
]))
markupTree
=
etree
.
fromstring
(
markup
)
# no matter xhtml or html with no namespace
imgsrc
=
markupTree
.
xpath
(
"//*[local-name() = 'img']/@src"
)
# imgsrc maybe startwith "../"" so fullpath join then relpath to cwd
filename
=
os
.
path
.
relpath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
join
(
coverpath
,
coversection
[
0
])),
imgsrc
[
0
]))
coverfile
=
extractCover
(
epubZip
,
filename
,
""
,
tmp_file_path
)
else
:
coverfile
=
extractCover
(
epubZip
,
coversection
[
0
],
coverpath
,
tmp_file_path
)
if
not
epub_metadata
[
'title'
]:
title
=
original_file_name
...
...
cps/templates/stats.html
View file @
a371e40c
{% extends "layout.html" %}
{% block body %}
<h3>
{{_('About')}}
</h3>
<p>
{{instance}} powered by
<p>
{{instance}} powered by
<a
href=
"https://github.com/janeczku/calibre-web"
title=
"Calibre-Web"
>
Calibre-Web
</a>
.
</p>
</p>
<h3>
{{_('Calibre library statistics')}}
</h3>
<table
id=
"stats"
class=
"table"
>
<tbody>
...
...
@@ -37,7 +37,7 @@
{% for library,version in versions.items() %}
<tr>
<th>
{{library}}
</th>
<td>
{{
version
}}
</td>
<td>
{{
_(version)
}}
</td>
</tr>
{% endfor %}
</tbody>
...
...
cps/translations/de/LC_MESSAGES/messages.mo
View file @
a371e40c
No preview for this file type
cps/translations/de/LC_MESSAGES/messages.po
View file @
a371e40c
...
...
@@ -5,18 +5,19 @@
# FIRST AUTHOR OzzieIsaacs, 2016.
msgid ""
msgstr ""
"Project-Id-Version:
Calibre-Web\n"
"Project-Id-Version: Calibre-Web\n"
"Report-Msgid-Bugs-To: https://github.com/janeczku/Calibre-Web\n"
"POT-Creation-Date: 2019-09-17 18:24+0200\n"
"PO-Revision-Date: 2019-
08-06 18:36
+0200\n"
"PO-Revision-Date: 2019-
10-20 15:14
+0200\n"
"Last-Translator: Ozzie Isaacs\n"
"Language: de\n"
"Language-Team: \n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"Plural-Forms: nplurals=2; plural=(n != 1)
;
\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.7.0\n"
"X-Generator: Poedit 2.2.4\n"
#: cps/about.py:40 cps/about.py:65 cps/about.py:66 cps/uploader.py:228
msgid "installed"
...
...
@@ -289,7 +290,7 @@ msgstr "Callback Domain ist nicht verifiziert, bitte Domain in der Google Develo
#: cps/helper.py:79
#, python-format
msgid "%(format)s format not found for book id: %(book)d"
msgstr "%(format)s Format für Buch-ID %(book)d nicht gefunden
"
msgstr "%(format)s Format für Buch-ID %(book)d nicht gefunden"
#: cps/helper.py:91
#, python-format
...
...
@@ -880,7 +881,7 @@ msgstr "Lese ein Buch"
#: cps/web.py:1332
msgid "Error opening eBook. File does not exist or file is not accessible."
msgstr "Fehler beim Öffnen des eBooks. Datei existiert nicht oder ist nicht zugänglich.
"
msgstr "Fehler beim Öffnen des eBooks. Datei existiert nicht oder ist nicht zugänglich."
#: cps/worker.py:328
#, python-format
...
...
@@ -2178,6 +2179,9 @@ msgstr "Benutzer löschen"
msgid "Recent Downloads"
msgstr "Letzte Downloads"
msgid "not configured"
msgstr "Nicht konfiguriert"
#~ msgid "Show sorted books"
#~ msgstr "Zeige Bücher sortiert"
...
...
@@ -2274,9 +2278,6 @@ msgstr "Letzte Downloads"
#~ msgid "Excecution permissions missing"
#~ msgstr "Ausführungsberechtigung nicht vorhanden"
#~ msgid "not configured"
#~ msgstr "Nicht konfiguriert"
#~ msgid "Error excecuting UnRar"
#~ msgstr "Fehler bei der Ausführung von UnRar"
...
...
@@ -2307,12 +2308,5 @@ msgstr "Letzte Downloads"
#~ msgid "Google OAuth Client Secret"
#~ msgstr "Google OAuth Client-Secret"
#~ msgid "Installed"
#~ msgstr ""
#~ msgid "Not installed"
#~ msgstr ""
#~ msgid "Use"
#~ msgstr "Benutzen"
cps/uploader.py
View file @
a371e40c
...
...
@@ -210,24 +210,24 @@ def get_versions():
IVersion
=
ImageVersion
.
MAGICK_VERSION
WVersion
=
ImageVersion
.
VERSION
else
:
IVersion
=
_
(
u'not installed'
)
WVersion
=
_
(
u'not installed'
)
IVersion
=
u'not installed'
WVersion
=
u'not installed'
if
use_pdf_meta
:
PVersion
=
'v'
+
PyPdfVersion
else
:
PVersion
=
_
(
u'not installed'
)
PVersion
=
u'not installed'
if
lxmlversion
:
XVersion
=
'v'
+
'.'
.
join
(
map
(
str
,
lxmlversion
))
else
:
XVersion
=
_
(
u'not installed'
)
XVersion
=
u'not installed'
if
use_PIL
:
PILVersion
=
'v'
+
PILversion
else
:
PILVersion
=
_
(
u'not installed'
)
PILVersion
=
u'not installed'
if
comic
.
use_comic_meta
:
ComicVersion
=
_
(
u'installed'
)
ComicVersion
=
u'installed'
else
:
ComicVersion
=
_
(
u'not installed'
)
ComicVersion
=
u'not installed'
return
{
'Image Magick'
:
IVersion
,
'PyPdf'
:
PVersion
,
'lxml'
:
XVersion
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment