|
|
@ -129,7 +129,7 @@ def HandleSyncRequest():
|
|
|
|
sync_token = SyncToken.SyncToken.from_headers(request.headers)
|
|
|
|
sync_token = SyncToken.SyncToken.from_headers(request.headers)
|
|
|
|
log.info("Kobo library sync request received.")
|
|
|
|
log.info("Kobo library sync request received.")
|
|
|
|
if not current_app.wsgi_app.is_proxied:
|
|
|
|
if not current_app.wsgi_app.is_proxied:
|
|
|
|
log.debug('Kobo: Received unproxied request, changed request port to server port')
|
|
|
|
log.debug('Kobo: Received unproxied request, changed request port to external server port')
|
|
|
|
|
|
|
|
|
|
|
|
# TODO: Limit the number of books return per sync call, and rely on the sync-continuatation header
|
|
|
|
# TODO: Limit the number of books return per sync call, and rely on the sync-continuatation header
|
|
|
|
# instead so that the device triggers another sync.
|
|
|
|
# instead so that the device triggers another sync.
|
|
|
@ -252,7 +252,7 @@ def generate_sync_response(sync_token, sync_results):
|
|
|
|
@download_required
|
|
|
|
@download_required
|
|
|
|
def HandleMetadataRequest(book_uuid):
|
|
|
|
def HandleMetadataRequest(book_uuid):
|
|
|
|
if not current_app.wsgi_app.is_proxied:
|
|
|
|
if not current_app.wsgi_app.is_proxied:
|
|
|
|
log.debug('Kobo: Received unproxied request, changed request port to server port')
|
|
|
|
log.debug('Kobo: Received unproxied request, changed request port to external server port')
|
|
|
|
log.info("Kobo library metadata request received for book %s" % book_uuid)
|
|
|
|
log.info("Kobo library metadata request received for book %s" % book_uuid)
|
|
|
|
book = calibre_db.get_book_by_uuid(book_uuid)
|
|
|
|
book = calibre_db.get_book_by_uuid(book_uuid)
|
|
|
|
if not book or not book.data:
|
|
|
|
if not book or not book.data:
|
|
|
@ -269,10 +269,11 @@ def get_download_url_for_book(book, book_format):
|
|
|
|
host = "".join(request.host.split(':')[:-1])
|
|
|
|
host = "".join(request.host.split(':')[:-1])
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
host = request.host
|
|
|
|
host = request.host
|
|
|
|
|
|
|
|
|
|
|
|
return "{url_scheme}://{url_base}:{url_port}/download/{book_id}/{book_format}".format(
|
|
|
|
return "{url_scheme}://{url_base}:{url_port}/download/{book_id}/{book_format}".format(
|
|
|
|
url_scheme=request.scheme,
|
|
|
|
url_scheme=request.scheme,
|
|
|
|
url_base=host,
|
|
|
|
url_base=host,
|
|
|
|
url_port=config.config_port,
|
|
|
|
url_port=config.config_external_port,
|
|
|
|
book_id=book.id,
|
|
|
|
book_id=book.id,
|
|
|
|
book_format=book_format.lower()
|
|
|
|
book_format=book_format.lower()
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -924,7 +925,7 @@ def HandleInitRequest():
|
|
|
|
kobo_resources = NATIVE_KOBO_RESOURCES()
|
|
|
|
kobo_resources = NATIVE_KOBO_RESOURCES()
|
|
|
|
|
|
|
|
|
|
|
|
if not current_app.wsgi_app.is_proxied:
|
|
|
|
if not current_app.wsgi_app.is_proxied:
|
|
|
|
log.debug('Kobo: Received unproxied request, changed request port to server port')
|
|
|
|
log.debug('Kobo: Received unproxied request, changed request port to external server port')
|
|
|
|
if ':' in request.host and not request.host.endswith(']'):
|
|
|
|
if ':' in request.host and not request.host.endswith(']'):
|
|
|
|
host = "".join(request.host.split(':')[:-1])
|
|
|
|
host = "".join(request.host.split(':')[:-1])
|
|
|
|
else:
|
|
|
|
else:
|
|
|
@ -932,8 +933,9 @@ def HandleInitRequest():
|
|
|
|
calibre_web_url = "{url_scheme}://{url_base}:{url_port}".format(
|
|
|
|
calibre_web_url = "{url_scheme}://{url_base}:{url_port}".format(
|
|
|
|
url_scheme=request.scheme,
|
|
|
|
url_scheme=request.scheme,
|
|
|
|
url_base=host,
|
|
|
|
url_base=host,
|
|
|
|
url_port=config.config_port
|
|
|
|
url_port=config.config_external_port
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
log.debug('Kobo: Received unproxied request, changed request url to %s', calibre_web_url)
|
|
|
|
kobo_resources["image_host"] = calibre_web_url
|
|
|
|
kobo_resources["image_host"] = calibre_web_url
|
|
|
|
kobo_resources["image_url_quality_template"] = unquote(calibre_web_url +
|
|
|
|
kobo_resources["image_url_quality_template"] = unquote(calibre_web_url +
|
|
|
|
url_for("kobo.HandleCoverImageRequest",
|
|
|
|
url_for("kobo.HandleCoverImageRequest",
|
|
|
@ -942,16 +944,14 @@ def HandleInitRequest():
|
|
|
|
width="{width}",
|
|
|
|
width="{width}",
|
|
|
|
height="{height}",
|
|
|
|
height="{height}",
|
|
|
|
Quality='{Quality}',
|
|
|
|
Quality='{Quality}',
|
|
|
|
isGreyscale='isGreyscale'
|
|
|
|
isGreyscale='isGreyscale'))
|
|
|
|
))
|
|
|
|
|
|
|
|
kobo_resources["image_url_template"] = unquote(calibre_web_url +
|
|
|
|
kobo_resources["image_url_template"] = unquote(calibre_web_url +
|
|
|
|
url_for("kobo.HandleCoverImageRequest",
|
|
|
|
url_for("kobo.HandleCoverImageRequest",
|
|
|
|
auth_token=kobo_auth.get_auth_token(),
|
|
|
|
auth_token=kobo_auth.get_auth_token(),
|
|
|
|
book_uuid="{ImageId}",
|
|
|
|
book_uuid="{ImageId}",
|
|
|
|
width="{width}",
|
|
|
|
width="{width}",
|
|
|
|
height="{height}",
|
|
|
|
height="{height}",
|
|
|
|
isGreyscale='false'
|
|
|
|
isGreyscale='false'))
|
|
|
|
))
|
|
|
|
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
kobo_resources["image_host"] = url_for("web.index", _external=True).strip("/")
|
|
|
|
kobo_resources["image_host"] = url_for("web.index", _external=True).strip("/")
|
|
|
|
kobo_resources["image_url_quality_template"] = unquote(url_for("kobo.HandleCoverImageRequest",
|
|
|
|
kobo_resources["image_url_quality_template"] = unquote(url_for("kobo.HandleCoverImageRequest",
|
|
|
@ -970,7 +970,6 @@ def HandleInitRequest():
|
|
|
|
isGreyscale='false',
|
|
|
|
isGreyscale='false',
|
|
|
|
_external=True))
|
|
|
|
_external=True))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
response = make_response(jsonify({"Resources": kobo_resources}))
|
|
|
|
response = make_response(jsonify({"Resources": kobo_resources}))
|
|
|
|
response.headers["x-kobo-apitoken"] = "e30="
|
|
|
|
response.headers["x-kobo-apitoken"] = "e30="
|
|
|
|
|
|
|
|
|
|
|
|