1
0
mirror of https://github.com/janeczku/calibre-web synced 2024-11-25 02:57:22 +00:00

should fix testing error

This commit is contained in:
Andriy Zasypkin 2017-12-20 11:54:19 -05:00
parent 6b6a457a9d
commit e66068d699
No known key found for this signature in database
GPG Key ID: 8686E6148F9D9BC2

View File

@ -31,9 +31,9 @@ except ImportError:
rar_support=False rar_support=False
try: try:
from natsort import natsorted as sorted from natsort import natsorted as sort
except ImportError: except ImportError:
pass # Just use regular sort then sort=sorted # Just use regular sort then
# may cause issues with badly named pages in cbz/cbr files # may cause issues with badly named pages in cbz/cbr files
import mimetypes import mimetypes
@ -937,7 +937,7 @@ def get_comic_book(book_id, book_format, page):
rarfile.UNRAR_TOOL = config.config_rarfile_location rarfile.UNRAR_TOOL = config.config_rarfile_location
try: try:
rf = rarfile.RarFile(cbr_file) rf = rarfile.RarFile(cbr_file)
rarNames = sorted(rf.namelist()) rarNames = sort(rf.namelist())
b64 = codecs.encode(rf.read(rarNames[page]), 'base64').decode() b64 = codecs.encode(rf.read(rarNames[page]), 'base64').decode()
extractedfile="data:image/png;base64," + b64 extractedfile="data:image/png;base64," + b64
fileData={"name": rarNames[page],"page":page, "last":rarNames.__len__()-1, "content": extractedfile} fileData={"name": rarNames[page],"page":page, "last":rarNames.__len__()-1, "content": extractedfile}
@ -951,7 +951,7 @@ def get_comic_book(book_id, book_format, page):
return "", 204 return "", 204
if book_format in ("cbz", "zip"): if book_format in ("cbz", "zip"):
zf = zipfile.ZipFile(cbr_file) zf = zipfile.ZipFile(cbr_file)
zipNames=sorted(zf.namelist()) zipNames=sort(zf.namelist())
if sys.version_info.major >= 3: if sys.version_info.major >= 3:
b64 = codecs.encode(zf.read(zipNames[page]), 'base64').decode() b64 = codecs.encode(zf.read(zipNames[page]), 'base64').decode()
else: else:
@ -961,7 +961,7 @@ def get_comic_book(book_id, book_format, page):
if book_format in ("cbt", "tar"): if book_format in ("cbt", "tar"):
tf = tarfile.TarFile(cbr_file) tf = tarfile.TarFile(cbr_file)
tarNames=sorted(tf.getnames()) tarNames=sort(tf.getnames())
if sys.version_info.major >= 3: if sys.version_info.major >= 3:
b64 = codecs.encode(tf.extractfile(tarNames[page]).read(), 'base64').decode() b64 = codecs.encode(tf.extractfile(tarNames[page]).read(), 'base64').decode()
else: else: