mirror of
https://github.com/janeczku/calibre-web
synced 2024-10-31 23:26:20 +00:00
Bugfix for comicapi
This commit is contained in:
parent
6261981656
commit
e9fb5d9f25
35
cps/comic.py
35
cps/comic.py
@ -41,11 +41,13 @@ def extractCover(tmp_file_name, original_file_extension):
|
|||||||
if use_comic_meta:
|
if use_comic_meta:
|
||||||
archive = ComicArchive(tmp_file_name)
|
archive = ComicArchive(tmp_file_name)
|
||||||
cover_data = None
|
cover_data = None
|
||||||
ext = os.path.splitext(archive.getPageName(0))
|
for index, name in enumerate(archive.getPageNameList()):
|
||||||
if len(ext) > 1:
|
ext = os.path.splitext(name)
|
||||||
extension = ext[1].lower()
|
if len(ext) > 1:
|
||||||
if extension == '.jpg' or extension == '.jpeg':
|
extension = ext[1].lower()
|
||||||
cover_data = archive.getPage(0)
|
if extension == '.jpg' or extension == '.jpeg':
|
||||||
|
cover_data = archive.getPage(index)
|
||||||
|
break
|
||||||
else:
|
else:
|
||||||
if original_file_extension.upper() == '.CBZ':
|
if original_file_extension.upper() == '.CBZ':
|
||||||
cf = zipfile.ZipFile(tmp_file_name)
|
cf = zipfile.ZipFile(tmp_file_name)
|
||||||
@ -53,7 +55,7 @@ def extractCover(tmp_file_name, original_file_extension):
|
|||||||
ext = os.path.splitext(name)
|
ext = os.path.splitext(name)
|
||||||
if len(ext) > 1:
|
if len(ext) > 1:
|
||||||
extension = ext[1].lower()
|
extension = ext[1].lower()
|
||||||
if extension == '.jpg':
|
if extension == '.jpg' or extension == '.jpeg':
|
||||||
cover_data = cf.read(name)
|
cover_data = cf.read(name)
|
||||||
break
|
break
|
||||||
elif original_file_extension.upper() == '.CBT':
|
elif original_file_extension.upper() == '.CBT':
|
||||||
@ -62,7 +64,7 @@ def extractCover(tmp_file_name, original_file_extension):
|
|||||||
ext = os.path.splitext(name)
|
ext = os.path.splitext(name)
|
||||||
if len(ext) > 1:
|
if len(ext) > 1:
|
||||||
extension = ext[1].lower()
|
extension = ext[1].lower()
|
||||||
if extension == '.jpg':
|
if extension == '.jpg' or extension == '.jpeg':
|
||||||
cover_data = cf.extractfile(name).read()
|
cover_data = cf.extractfile(name).read()
|
||||||
break
|
break
|
||||||
prefix = os.path.dirname(tmp_file_name)
|
prefix = os.path.dirname(tmp_file_name)
|
||||||
@ -87,16 +89,17 @@ def get_comic_info(tmp_file_path, original_file_name, original_file_extension):
|
|||||||
else:
|
else:
|
||||||
style = None
|
style = None
|
||||||
|
|
||||||
if style is not None:
|
# if style is not None:
|
||||||
loadedMetadata = archive.readMetadata(style)
|
loadedMetadata = archive.readMetadata(style)
|
||||||
|
|
||||||
lang = loadedMetadata.language
|
lang = loadedMetadata.language
|
||||||
if len(lang) == 2:
|
if lang:
|
||||||
loadedMetadata.language = isoLanguages.get(part1=lang).name
|
if len(lang) == 2:
|
||||||
elif len(lang) == 3:
|
loadedMetadata.language = isoLanguages.get(part1=lang).name
|
||||||
loadedMetadata.language = isoLanguages.get(part3=lang).name
|
elif len(lang) == 3:
|
||||||
else:
|
loadedMetadata.language = isoLanguages.get(part3=lang).name
|
||||||
loadedMetadata.language = ""
|
else:
|
||||||
|
loadedMetadata.language = ""
|
||||||
|
|
||||||
return BookMeta(
|
return BookMeta(
|
||||||
file_path=tmp_file_path,
|
file_path=tmp_file_path,
|
||||||
|
Loading…
Reference in New Issue
Block a user