Merge remote-tracking branch 'github_3/hotfix/epub-import'

Improved cover extraction from epub files
pull/1073/head
Ozzieisaacs 5 years ago
commit a371e40c66

@ -37,6 +37,7 @@ except ImportError:
from flask_login.__about__ import __version__ as flask_loginVersion from flask_login.__about__ import __version__ as flask_loginVersion
try: try:
import unidecode import unidecode
# _() necessary to make babel aware of string for translation
unidecode_version = _(u'installed') unidecode_version = _(u'installed')
except ImportError: except ImportError:
unidecode_version = _(u'not installed') unidecode_version = _(u'not installed')
@ -62,8 +63,8 @@ _VERSIONS = OrderedDict(
iso639=isoLanguages.__version__, iso639=isoLanguages.__version__,
pytz=pytz.__version__, pytz=pytz.__version__,
Unidecode = unidecode_version, Unidecode = unidecode_version,
Flask_SimpleLDAP = _(u'installed') if bool(services.ldap) 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'), Goodreads = u'installed' if bool(services.goodreads_support) else u'not installed',
) )
_VERSIONS.update(uploader.get_versions()) _VERSIONS.update(uploader.get_versions())

@ -19,6 +19,7 @@
from __future__ import division, print_function, unicode_literals from __future__ import division, print_function, unicode_literals
import os import os
import re import re
from flask_babel import gettext as _
from . import config, logger from . import config, logger
from .subproc_wrapper import process_wait from .subproc_wrapper import process_wait
@ -26,7 +27,8 @@ from .subproc_wrapper import process_wait
log = logger.create() log = logger.create()
_NOT_CONFIGURED = 'not configured' # _() necessary to make babel aware of string for translation
_NOT_CONFIGURED = _('not configured')
_NOT_INSTALLED = 'not installed' _NOT_INSTALLED = 'not installed'
_EXECUTION_ERROR = 'Execution permissions missing' _EXECUTION_ERROR = 'Execution permissions missing'

@ -64,6 +64,11 @@ def get_epub_info(tmp_file_path, original_file_name, original_file_extension):
for s in ['title', 'description', 'creator', 'language', 'subject']: for s in ['title', 'description', 'creator', 'language', 'subject']:
tmp = p.xpath('dc:%s/text()' % s, namespaces=ns) tmp = p.xpath('dc:%s/text()' % s, namespaces=ns)
if len(tmp) > 0: if len(tmp) > 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] epub_metadata[s] = p.xpath('dc:%s/text()' % s, namespaces=ns)[0]
else: else:
epub_metadata[s] = "Unknown" epub_metadata[s] = "Unknown"
@ -109,6 +114,8 @@ 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) meta_cover = tree.xpath("/pkg:package/pkg:metadata/pkg:meta[@name='cover']/@content", namespaces=ns)
if len(meta_cover) > 0: if len(meta_cover) > 0:
coversection = tree.xpath("/pkg:package/pkg:manifest/pkg:item[@id='"+meta_cover[0]+"']/@href", namespaces=ns) coversection = tree.xpath("/pkg:package/pkg:manifest/pkg:item[@id='"+meta_cover[0]+"']/@href", namespaces=ns)
else:
coversection = tree.xpath("/pkg:package/pkg:guide/pkg:reference/@href", namespaces=ns)
if len(coversection) > 0: if len(coversection) > 0:
filetype = coversection[0].rsplit('.', 1)[-1] filetype = coversection[0].rsplit('.', 1)[-1]
if filetype == "xhtml" or filetype == "html": # if cover is (x)html format if filetype == "xhtml" or filetype == "html": # if cover is (x)html format

@ -37,7 +37,7 @@
{% for library,version in versions.items() %} {% for library,version in versions.items() %}
<tr> <tr>
<th>{{library}}</th> <th>{{library}}</th>
<td>{{version}}</td> <td>{{_(version)}}</td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>

@ -8,15 +8,16 @@ msgstr ""
"Project-Id-Version: Calibre-Web\n" "Project-Id-Version: Calibre-Web\n"
"Report-Msgid-Bugs-To: https://github.com/janeczku/Calibre-Web\n" "Report-Msgid-Bugs-To: https://github.com/janeczku/Calibre-Web\n"
"POT-Creation-Date: 2019-09-17 18:24+0200\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" "Last-Translator: Ozzie Isaacs\n"
"Language: de\n" "Language: de\n"
"Language-Team: \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" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n" "Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.7.0\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 #: cps/about.py:40 cps/about.py:65 cps/about.py:66 cps/uploader.py:228
msgid "installed" msgid "installed"
@ -2178,6 +2179,9 @@ msgstr "Benutzer löschen"
msgid "Recent Downloads" msgid "Recent Downloads"
msgstr "Letzte Downloads" msgstr "Letzte Downloads"
msgid "not configured"
msgstr "Nicht konfiguriert"
#~ msgid "Show sorted books" #~ msgid "Show sorted books"
#~ msgstr "Zeige Bücher sortiert" #~ msgstr "Zeige Bücher sortiert"
@ -2274,9 +2278,6 @@ msgstr "Letzte Downloads"
#~ msgid "Excecution permissions missing" #~ msgid "Excecution permissions missing"
#~ msgstr "Ausführungsberechtigung nicht vorhanden" #~ msgstr "Ausführungsberechtigung nicht vorhanden"
#~ msgid "not configured"
#~ msgstr "Nicht konfiguriert"
#~ msgid "Error excecuting UnRar" #~ msgid "Error excecuting UnRar"
#~ msgstr "Fehler bei der Ausführung von UnRar" #~ msgstr "Fehler bei der Ausführung von UnRar"
@ -2307,12 +2308,5 @@ msgstr "Letzte Downloads"
#~ msgid "Google OAuth Client Secret" #~ msgid "Google OAuth Client Secret"
#~ msgstr "Google OAuth Client-Secret" #~ msgstr "Google OAuth Client-Secret"
#~ msgid "Installed"
#~ msgstr ""
#~ msgid "Not installed"
#~ msgstr ""
#~ msgid "Use" #~ msgid "Use"
#~ msgstr "Benutzen" #~ msgstr "Benutzen"

@ -210,24 +210,24 @@ def get_versions():
IVersion = ImageVersion.MAGICK_VERSION IVersion = ImageVersion.MAGICK_VERSION
WVersion = ImageVersion.VERSION WVersion = ImageVersion.VERSION
else: else:
IVersion = _(u'not installed') IVersion = u'not installed'
WVersion = _(u'not installed') WVersion = u'not installed'
if use_pdf_meta: if use_pdf_meta:
PVersion='v'+PyPdfVersion PVersion='v'+PyPdfVersion
else: else:
PVersion=_(u'not installed') PVersion=u'not installed'
if lxmlversion: if lxmlversion:
XVersion = 'v'+'.'.join(map(str, lxmlversion)) XVersion = 'v'+'.'.join(map(str, lxmlversion))
else: else:
XVersion = _(u'not installed') XVersion = u'not installed'
if use_PIL: if use_PIL:
PILVersion = 'v' + PILversion PILVersion = 'v' + PILversion
else: else:
PILVersion = _(u'not installed') PILVersion = u'not installed'
if comic.use_comic_meta: if comic.use_comic_meta:
ComicVersion = _(u'installed') ComicVersion = u'installed'
else: else:
ComicVersion = _(u'not installed') ComicVersion = u'not installed'
return {'Image Magick': IVersion, return {'Image Magick': IVersion,
'PyPdf': PVersion, 'PyPdf': PVersion,
'lxml':XVersion, 'lxml':XVersion,

Loading…
Cancel
Save