|
25 | 25 | from time import gmtime, strftime |
26 | 26 | import json |
27 | 27 | from urllib.parse import unquote |
| 28 | +import uuid |
28 | 29 |
|
29 | 30 | from flask import ( |
30 | 31 | Blueprint, |
@@ -512,10 +513,22 @@ def get_metadata(book): |
512 | 513 | log.error(e) |
513 | 514 |
|
514 | 515 | book_uuid = book.uuid |
| 516 | + |
| 517 | + thumbnail_generated_at = ( |
| 518 | + calibre_db.session |
| 519 | + .query(ub.Thumbnail.generated_at) |
| 520 | + .filter(ub.Thumbnail.entity_id == book.id) |
| 521 | + .order_by(ub.Thumbnail.id) |
| 522 | + .limit(1) |
| 523 | + ).scalar() |
| 524 | + |
| 525 | + #turn thumbnail generated_at timestamp into an epoch for use as the version |
| 526 | + version_str = f"{thumbnail_generated_at.timestamp():.0f}" |
| 527 | + |
515 | 528 | metadata = { |
516 | 529 | "Categories": ["00000000-0000-0000-0000-000000000001", ], |
517 | 530 | # "Contributors": get_author(book), |
518 | | - "CoverImageId": book_uuid, |
| 531 | + "CoverImageId": book_uuid+"/"+version_str, |
519 | 532 | "CrossRevisionId": book_uuid, |
520 | 533 | "CurrentDisplayPrice": {"CurrencyCode": "USD", "TotalAmount": 0}, |
521 | 534 | "CurrentLoveDisplayPrice": {"TotalAmount": 0}, |
@@ -954,10 +967,12 @@ def get_current_bookmark_response(current_bookmark): |
954 | 967 | return resp |
955 | 968 |
|
956 | 969 |
|
957 | | -@kobo.route("/<book_uuid>/<width>/<height>/<isGreyscale>/image.jpg", defaults={'Quality': ""}) |
958 | | -@kobo.route("/<book_uuid>/<width>/<height>/<Quality>/<isGreyscale>/image.jpg") |
| 970 | +@kobo.route("/<book_uuid>/<width>/<height>/<isGreyscale>/image.jpg", defaults={'Quality': "", 'version': ""}) |
| 971 | +@kobo.route("/<book_uuid>/<width>/<height>/<Quality>/<isGreyscale>/image.jpg", defaults={'version': ""}) |
| 972 | +@kobo.route("/<book_uuid>/<version>/<width>/<height>/<isGreyscale>/image.jpg", defaults={'Quality': ""}) |
| 973 | +@kobo.route("/<book_uuid>/<version>/<width>/<height>/<Quality>/<isGreyscale>/image.jpg") |
959 | 974 | @requires_kobo_auth |
960 | | -def HandleCoverImageRequest(book_uuid, width, height, Quality, isGreyscale): |
| 975 | +def HandleCoverImageRequest(book_uuid, version, width, height, Quality, isGreyscale): |
961 | 976 | try: |
962 | 977 | if int(height) > 1000: |
963 | 978 | resolution = COVER_THUMBNAIL_LARGE |
|
0 commit comments