Fix proxy cover images to Kobo store

This commit is contained in:
Thomas de Ruiter 2023-03-28 15:56:02 +02:00
parent 38484624e9
commit 5f0c7737fe
2 changed files with 8 additions and 4 deletions

View File

@ -747,9 +747,10 @@ def get_book_cover(book_id, resolution=None):
return get_book_cover_internal(book, use_generic_cover_on_failure=True, resolution=resolution)
# Called only by kobo sync -> cover not found should be answered with 404 and not with default cover
def get_book_cover_with_uuid(book_uuid, resolution=None):
def get_book_cover_with_uuid(book_uuid, resolution=None, none_on_missing=False):
book = calibre_db.get_book_by_uuid(book_uuid)
if not book and none_on_missing:
return # allows kobo.HandleCoverImageRequest to proxy request
return get_book_cover_internal(book, use_generic_cover_on_failure=False, resolution=resolution)

View File

@ -930,7 +930,10 @@ def get_current_bookmark_response(current_bookmark):
@kobo.route("/<book_uuid>/<width>/<height>/<Quality>/<isGreyscale>/image.jpg")
@requires_kobo_auth
def HandleCoverImageRequest(book_uuid, width, height, Quality, isGreyscale):
book_cover = helper.get_book_cover_with_uuid(book_uuid, resolution=COVER_THUMBNAIL_SMALL)
book_cover = helper.get_book_cover_with_uuid(
book_uuid,
resolution=COVER_THUMBNAIL_SMALL,
none_on_missing=config.config_kobo_proxy)
if not book_cover:
if config.config_kobo_proxy:
log.debug("Cover for unknown book: %s proxied to kobo" % book_uuid)
@ -941,7 +944,7 @@ def HandleCoverImageRequest(book_uuid, width, height, Quality, isGreyscale):
else:
log.debug("Cover for unknown book: %s requested" % book_uuid)
# additional proxy request make no sense, -> direct return
return make_response(jsonify({}))
return abort(404)
log.debug("Cover request received for book %s" % book_uuid)
return book_cover