From 91a21ababe755b4346bae0e55bebb0124b7a2e9a Mon Sep 17 00:00:00 2001 From: Ozzie Isaacs Date: Sat, 4 Dec 2021 11:16:33 +0100 Subject: [PATCH] Allow download of archived books --- cps/helper.py | 2 +- cps/kobo.py | 19 +++++++++---------- cps/services/SyncToken.py | 5 ++--- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/cps/helper.py b/cps/helper.py index d966b331..2c2c3cad 100644 --- a/cps/helper.py +++ b/cps/helper.py @@ -823,7 +823,7 @@ def get_cc_columns(filter_config_custom_read=False): def get_download_link(book_id, book_format, client): book_format = book_format.split(".")[0] - book = calibre_db.get_filtered_book(book_id) + book = calibre_db.get_filtered_book(book_id, allow_show_archived=True) if book: data1 = calibre_db.get_book_format(book.id, book_format.upper()) else: diff --git a/cps/kobo.py b/cps/kobo.py index 3d2af7f4..653321cb 100644 --- a/cps/kobo.py +++ b/cps/kobo.py @@ -355,7 +355,9 @@ def HandleMetadataRequest(book_uuid): return redirect_or_proxy_request() metadata = get_metadata(book) - return jsonify([metadata]) + response = make_response(json.dumps([metadata])) + response.headers["Content-Type"] = "application/json; charset=utf-8" + return response def get_download_url_for_book(book, book_format): @@ -413,15 +415,12 @@ def get_description(book): def get_author(book): if not book.authors: return {"Contributors": None} - if len(book.authors) > 1: - author_list = [] - autor_roles = [] - for author in book.authors: - autor_roles.append({"Name":author.name}) #.encode('unicode-escape').decode('latin-1') - author_list.append(author.name) - return {"ContributorRoles": autor_roles, "Contributors":author_list} - return {"ContributorRoles": [{"Name":book.authors[0].name}], - "Contributors": book.authors[0].name} + author_list = [] + autor_roles = [] + for author in book.authors: + autor_roles.append({"Name":author.name}) #.encode('unicode-escape').decode('latin-1') + author_list.append(author.name) + return {"ContributorRoles": autor_roles, "Contributors":author_list} def get_publisher(book): diff --git a/cps/services/SyncToken.py b/cps/services/SyncToken.py index 692aaa24..85ed5032 100644 --- a/cps/services/SyncToken.py +++ b/cps/services/SyncToken.py @@ -182,10 +182,9 @@ class SyncToken: return b64encode_json(token) def __str__(self): - return "{},{},{},{},{},{}".format(self.raw_kobo_store_token, - self.books_last_created, + return "{},{},{},{},{},{}".format(self.books_last_created, self.books_last_modified, self.archive_last_modified, self.reading_state_last_modified, - self.tags_last_modified) + self.tags_last_modified, self.raw_kobo_store_token) #self.books_last_id)