mirror of
https://github.com/janeczku/calibre-web
synced 2024-11-24 18:47:23 +00:00
comic book read file order fixed
This commit is contained in:
parent
03e2a1e73b
commit
9249390043
12
cps/web.py
12
cps/web.py
@ -30,6 +30,12 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
rar_support=False
|
rar_support=False
|
||||||
|
|
||||||
|
try:
|
||||||
|
from natsort import natsorted as sorted
|
||||||
|
except ImportError:
|
||||||
|
pass # Just use regular sort then
|
||||||
|
# may cause issues with badly named pages in cbz/cbr files
|
||||||
|
|
||||||
import mimetypes
|
import mimetypes
|
||||||
import logging
|
import logging
|
||||||
from logging.handlers import RotatingFileHandler
|
from logging.handlers import RotatingFileHandler
|
||||||
@ -931,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 = rf.namelist()
|
rarNames = sorted(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}
|
||||||
@ -945,7 +951,7 @@ def get_comic_book(book_id, book_format, page):
|
|||||||
return "", 204
|
return "", 204
|
||||||
if book_format == "cbz":
|
if book_format == "cbz":
|
||||||
zf = zipfile.ZipFile(cbr_file)
|
zf = zipfile.ZipFile(cbr_file)
|
||||||
zipNames=zf.namelist()
|
zipNames=sorted(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:
|
||||||
@ -955,7 +961,7 @@ def get_comic_book(book_id, book_format, page):
|
|||||||
|
|
||||||
if book_format == "cbt":
|
if book_format == "cbt":
|
||||||
tf = tarfile.TarFile(u'D:\\zip\\test.cbt')
|
tf = tarfile.TarFile(u'D:\\zip\\test.cbt')
|
||||||
tarNames=tf.getnames()
|
tarNames=sorted(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:
|
||||||
|
@ -14,3 +14,4 @@ uritemplate==3.0.0
|
|||||||
goodreads>=0.3.2
|
goodreads>=0.3.2
|
||||||
python-Levenshtein>=0.12.0
|
python-Levenshtein>=0.12.0
|
||||||
rarfile>=2.7
|
rarfile>=2.7
|
||||||
|
natsort>=2.2.0
|
||||||
|
Loading…
Reference in New Issue
Block a user