|
|
@ -523,7 +523,7 @@ def save_cover(img, book_path):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def do_download_file(book, book_format, data, headers):
|
|
|
|
def do_download_file(book, book_format, client, data, headers):
|
|
|
|
if config.config_use_google_drive:
|
|
|
|
if config.config_use_google_drive:
|
|
|
|
startTime = time.time()
|
|
|
|
startTime = time.time()
|
|
|
|
df = gd.getFileFromEbooksFolder(book.path, data.name + "." + book_format)
|
|
|
|
df = gd.getFileFromEbooksFolder(book.path, data.name + "." + book_format)
|
|
|
@ -537,7 +537,18 @@ def do_download_file(book, book_format, data, headers):
|
|
|
|
if not os.path.isfile(os.path.join(filename, data.name + "." + book_format)):
|
|
|
|
if not os.path.isfile(os.path.join(filename, data.name + "." + book_format)):
|
|
|
|
# ToDo: improve error handling
|
|
|
|
# ToDo: improve error handling
|
|
|
|
log.error('File not found: %s', os.path.join(filename, data.name + "." + book_format))
|
|
|
|
log.error('File not found: %s', os.path.join(filename, data.name + "." + book_format))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if client == "kobo" and book_format == "epub":
|
|
|
|
|
|
|
|
filename = config.config_kepub_cache_dir
|
|
|
|
|
|
|
|
os.system('{0} "{1}" -o {2}'.format(
|
|
|
|
|
|
|
|
config.config_kepubify_path,
|
|
|
|
|
|
|
|
os.path.join(filename, data.name + "." + book_format),
|
|
|
|
|
|
|
|
filename))
|
|
|
|
|
|
|
|
book_format = "kepub.epub"
|
|
|
|
|
|
|
|
headers["Content-Disposition"] = headers["Content-Disposition"].replace(".epub", ".kepub.epub")
|
|
|
|
|
|
|
|
|
|
|
|
response = make_response(send_from_directory(filename, data.name + "." + book_format))
|
|
|
|
response = make_response(send_from_directory(filename, data.name + "." + book_format))
|
|
|
|
|
|
|
|
|
|
|
|
response.headers = headers
|
|
|
|
response.headers = headers
|
|
|
|
return response
|
|
|
|
return response
|
|
|
|
|
|
|
|
|
|
|
@ -756,7 +767,7 @@ def get_cc_columns():
|
|
|
|
cc = tmpcc
|
|
|
|
cc = tmpcc
|
|
|
|
return cc
|
|
|
|
return cc
|
|
|
|
|
|
|
|
|
|
|
|
def get_download_link(book_id, book_format):
|
|
|
|
def get_download_link(book_id, book_format, client):
|
|
|
|
book_format = book_format.split(".")[0]
|
|
|
|
book_format = book_format.split(".")[0]
|
|
|
|
book = db.session.query(db.Books).filter(db.Books.id == book_id).filter(common_filters()).first()
|
|
|
|
book = db.session.query(db.Books).filter(db.Books.id == book_id).filter(common_filters()).first()
|
|
|
|
if book:
|
|
|
|
if book:
|
|
|
@ -776,7 +787,8 @@ def get_download_link(book_id, book_format):
|
|
|
|
headers["Content-Type"] = mimetypes.types_map.get('.' + book_format, "application/octet-stream")
|
|
|
|
headers["Content-Type"] = mimetypes.types_map.get('.' + book_format, "application/octet-stream")
|
|
|
|
headers["Content-Disposition"] = "attachment; filename*=UTF-8''%s.%s" % (quote(file_name.encode('utf-8')),
|
|
|
|
headers["Content-Disposition"] = "attachment; filename*=UTF-8''%s.%s" % (quote(file_name.encode('utf-8')),
|
|
|
|
book_format)
|
|
|
|
book_format)
|
|
|
|
return do_download_file(book, book_format, data, headers)
|
|
|
|
|
|
|
|
|
|
|
|
return do_download_file(book, book_format, client, data, headers)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
abort(404)
|
|
|
|
abort(404)
|
|
|
|
|
|
|
|
|
|
|
|