diff --git a/cps/templates/detail.html b/cps/templates/detail.html index 4a9fa8fb..2e685d36f 100644 --- a/cps/templates/detail.html +++ b/cps/templates/detail.html @@ -21,9 +21,9 @@ {{_('Download')}} : {% for format in entry.data %} - - {{format.format}} ({{ format.uncompressed_size|filesizeformat }}) - + + {{format.format}} ({{ format.uncompressed_size|filesizeformat }}) + {% endfor %} {% else %}
{% endif %} @@ -50,9 +50,9 @@ diff --git a/cps/web.py b/cps/web.py index 2e0aec9e..4ae940b3 100755 --- a/cps/web.py +++ b/cps/web.py @@ -99,6 +99,7 @@ try: except ImportError: from flask_login.__about__ import __version__ as flask_loginVersion +import codecs import time current_milli_time = lambda: int(round(time.time() * 1000)) @@ -931,7 +932,8 @@ def get_comic_book(book_id, book_format, page): try: rf = rarfile.RarFile(cbr_file) rarNames = rf.namelist() - extractedfile="data:image/png;base64," + (rf.read(rarNames[page])).encode('base64') + b64 = codecs.encode(rf.read(rarNames[page]), 'base64').decode() + extractedfile="data:image/png;base64," + b64 fileData={"name": rarNames[page],"page":page, "last":rarNames.__len__()-1, "content": extractedfile} except: # rarfile not valid @@ -944,15 +946,24 @@ def get_comic_book(book_id, book_format, page): if book_format == "cbz": zf = zipfile.ZipFile(cbr_file) zipNames=zf.namelist() - extractedfile="data:image/png;base64," + (zf.read(zipNames[page])).encode('base64') + if sys.version_info.major >= 3: + b64 = codecs.encode(zf.read(zipNames[page]), 'base64').decode() + else: + b64 = zf.read(zipNames[page]).encode('base64') + extractedfile="data:image/png;base64," + b64 fileData={"name": zipNames[page],"page":page, "last":zipNames.__len__()-1, "content": extractedfile} if book_format == "cbt": tf = tarfile.TarFile(u'D:\\zip\\test.cbt') tarNames=tf.getnames() - extractedfile="data:image/png;base64," + (tf.extractfile(tarNames[page]).read()).encode('base64') + if sys.version_info.major >= 3: + b64 = codecs.encode(tf.extractfile(tarNames[page]).read(), 'base64').decode() + else: + b64 = (tf.extractfile(tarNames[page]).read()).encode('base64') + extractedfile="data:image/png;base64," + bs fileData={"name": tarNames[page],"page":page, "last":tarNames.__len__()-1, "content": extractedfile} return make_response(json.dumps(fileData)) + return "", 204 @app.route("/ajax/toggleread/