From 5afff2231e1a6b209167811c70f101e8d5efa1f3 Mon Sep 17 00:00:00 2001 From: Ozzie Isaacs Date: Sat, 11 Nov 2023 10:43:50 +0100 Subject: [PATCH 1/4] Fix for #2743 (read status is no longer implicitly added to advanced search query) --- cps/search.py | 9 +++++---- cps/templates/search_form.html | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/cps/search.py b/cps/search.py index 4eee2206..f214b3a8 100644 --- a/cps/search.py +++ b/cps/search.py @@ -217,8 +217,8 @@ def extend_search_term(searchterm, searchterm.extend([_("Rating <= %(rating)s", rating=rating_high)]) if rating_low: searchterm.extend([_("Rating >= %(rating)s", rating=rating_low)]) - if read_status: - searchterm.extend([_("Read Status = %(status)s", status=read_status)]) + if read_status != "Any": + searchterm.extend([_("Read Status = '%(status)s'", status=read_status)]) searchterm.extend(ext for ext in tags['include_extension']) searchterm.extend(ext for ext in tags['exclude_extension']) # handle custom columns @@ -283,7 +283,7 @@ def render_adv_search_results(term, offset=None, order=None, limit=None): cc_present = True if any(tags.values()) or author_name or book_title or publisher or pub_start or pub_end or rating_low \ - or rating_high or description or cc_present or read_status: + or rating_high or description or cc_present or read_status != "Any": search_term, pub_start, pub_end = extend_search_term(search_term, author_name, book_title, @@ -302,7 +302,8 @@ def render_adv_search_results(term, offset=None, order=None, limit=None): q = q.filter(func.datetime(db.Books.pubdate) > func.datetime(pub_start)) if pub_end: q = q.filter(func.datetime(db.Books.pubdate) < func.datetime(pub_end)) - q = q.filter(adv_search_read_status(read_status)) + if read_status != "Any": + q = q.filter(adv_search_read_status(read_status)) if publisher: q = q.filter(db.Books.publishers.any(func.lower(db.Publishers.name).ilike("%" + publisher + "%"))) q = adv_search_tag(q, tags['include_tag'], tags['exclude_tag']) diff --git a/cps/templates/search_form.html b/cps/templates/search_form.html index 030d8585..cf2fac04 100644 --- a/cps/templates/search_form.html +++ b/cps/templates/search_form.html @@ -41,7 +41,8 @@
From 9841a4d068a7150c32aa40986e49b5c3434a046e Mon Sep 17 00:00:00 2001 From: ye Date: Sun, 26 Nov 2023 09:06:25 +0800 Subject: [PATCH 2/4] fix the the problem that metadata_provider/douban.py can't get tags info --- cps/metadata_provider/douban.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cps/metadata_provider/douban.py b/cps/metadata_provider/douban.py index 8e27e82e..39c71cc7 100644 --- a/cps/metadata_provider/douban.py +++ b/cps/metadata_provider/douban.py @@ -169,7 +169,8 @@ class Douban(Metadata): ), ) - html = etree.HTML(r.content.decode("utf8")) + decode_content = r.content.decode("utf8") + html = etree.HTML(decode_content) match.title = html.xpath(self.TITTLE_XPATH)[0].text match.cover = html.xpath( @@ -184,7 +185,7 @@ class Douban(Metadata): if len(tag_elements): match.tags = [tag_element.text for tag_element in tag_elements] else: - match.tags = self._get_tags(html.text) + match.tags = self._get_tags(decode_content) description_element = html.xpath(self.DESCRIPTION_XPATH) if len(description_element): From 400c74569280e2eb5d48cfd32761a24224ae0ec9 Mon Sep 17 00:00:00 2001 From: Russell Troxel Date: Sun, 26 Nov 2023 14:31:24 -0800 Subject: [PATCH 3/4] Update KOBO_IMAGEHOST_URL to new CDN endpoint Kobo has introduced a vanity URL to their Akamai CDN config - "https://https://cdn.kobo.com". As a result, requests sent to the old raw Akamai endpoint now through 404s. This is a simple PR that updates to the new URL. This is visible in the config of a newly bought Kobo Sage (mine): ``` image_host=https://cdn.kobo.com/book-images/ image_url_quality_template=https://cdn.kobo.com/book-images/{ImageId}/{Width}/{Height}/{Quality}/{IsGreyscale}/image.jpg image_url_template=https://cdn.kobo.com/book-images/{ImageId}/{Width}/{Height}/false/image.jpg ``` Example: OLD: https://kbimages1-a.akamaihd.net/1abfb307-457b-4597-b2ea-74beb2eb1478/149/223/false/image.jpg (Throws 404) New: https://cdn.kobo.com/book-images/1abfb307-457b-4597-b2ea-74beb2eb1478/149/223/false/image.jpg (Renders Properly) fixes #2371 ref #2731 --- cps/kobo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cps/kobo.py b/cps/kobo.py index f215e5aa..b2b5989b 100644 --- a/cps/kobo.py +++ b/cps/kobo.py @@ -56,7 +56,7 @@ from .kobo_auth import requires_kobo_auth, get_auth_token KOBO_FORMATS = {"KEPUB": ["KEPUB"], "EPUB": ["EPUB3", "EPUB"]} KOBO_STOREAPI_URL = "https://storeapi.kobo.com" -KOBO_IMAGEHOST_URL = "https://kbimages1-a.akamaihd.net" +KOBO_IMAGEHOST_URL = "https://cdn.kobo.com/book-images/" SYNC_ITEM_LIMIT = 100 From 01108aac42c393bdcb4cf1fc92532b36ad4e1bde Mon Sep 17 00:00:00 2001 From: Russell Date: Sun, 26 Nov 2023 22:01:26 -0800 Subject: [PATCH 4/4] Remove trailing slash Signed-off-by: Russell --- cps/kobo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cps/kobo.py b/cps/kobo.py index b2b5989b..76530797 100644 --- a/cps/kobo.py +++ b/cps/kobo.py @@ -56,7 +56,7 @@ from .kobo_auth import requires_kobo_auth, get_auth_token KOBO_FORMATS = {"KEPUB": ["KEPUB"], "EPUB": ["EPUB3", "EPUB"]} KOBO_STOREAPI_URL = "https://storeapi.kobo.com" -KOBO_IMAGEHOST_URL = "https://cdn.kobo.com/book-images/" +KOBO_IMAGEHOST_URL = "https://cdn.kobo.com/book-images" SYNC_ITEM_LIMIT = 100