From 8a5112502d37ff88daf768e8a856990bae576322 Mon Sep 17 00:00:00 2001 From: Martin Brodbeck Date: Fri, 12 Aug 2022 11:51:26 +0200 Subject: [PATCH 1/2] Considers the language of the ebook instead of always specifying "English". --- cps/kobo.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cps/kobo.py b/cps/kobo.py index c379e9a2..e886d95b 100644 --- a/cps/kobo.py +++ b/cps/kobo.py @@ -443,6 +443,12 @@ def get_seriesindex(book): return book.series_index or 1 +def get_language(book): + if not book.languages: + return 'en' + return book.languages[0].lang_code + + def get_metadata(book): download_urls = [] kepub = [data for data in book.data if data.format == 'KEPUB'] @@ -480,7 +486,7 @@ def get_metadata(book): "IsInternetArchive": False, "IsPreOrder": False, "IsSocialEnabled": True, - "Language": "en", + "Language": get_language(book), "PhoneticPronunciations": {}, "PublicationDate": convert_to_kobo_timestamp_string(book.pubdate), "Publisher": {"Imprint": "", "Name": get_publisher(book), }, From cd143b7ef4b6232ca28f2acf15cff8162f426998 Mon Sep 17 00:00:00 2001 From: Martin Brodbeck Date: Fri, 12 Aug 2022 15:18:50 +0200 Subject: [PATCH 2/2] Use part1 instead of part3 language codes --- cps/kobo.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cps/kobo.py b/cps/kobo.py index e886d95b..9814e83d 100644 --- a/cps/kobo.py +++ b/cps/kobo.py @@ -45,6 +45,7 @@ import requests from . import config, logger, kobo_auth, db, calibre_db, helper, shelf as shelf_lib, ub, csrf, kobo_sync_status +from . import isoLanguages from .constants import sqlalchemy_version2, COVER_THUMBNAIL_SMALL from .helper import get_download_link from .services import SyncToken as SyncToken @@ -446,7 +447,7 @@ def get_seriesindex(book): def get_language(book): if not book.languages: return 'en' - return book.languages[0].lang_code + return isoLanguages.get(part3=book.languages[0].lang_code).part1 def get_metadata(book):