From fc9a9cb9ac3c83826ed0cc38391a110df83b9328 Mon Sep 17 00:00:00 2001 From: Ozzie Isaacs Date: Sat, 11 May 2024 09:03:22 +0200 Subject: [PATCH 1/2] Fix for #3016 (Parsing lubimyczytac: Tags instead of categories are taken, translator is appended to description) --- cps/metadata_provider/lubimyczytac.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cps/metadata_provider/lubimyczytac.py b/cps/metadata_provider/lubimyczytac.py index 4644cad9..1dde42e7 100644 --- a/cps/metadata_provider/lubimyczytac.py +++ b/cps/metadata_provider/lubimyczytac.py @@ -97,12 +97,14 @@ class LubimyCzytac(Metadata): LANGUAGES = f"{CONTAINER}//dt[contains(text(),'Język:')]{SIBLINGS}/text()" DESCRIPTION = f"{CONTAINER}//div[@class='collapse-content']" SERIES = f"{CONTAINER}//span/a[contains(@href,'/cykl/')]/text()" + TRANSLATOR = f"{CONTAINER}//dt[contains(text(),'Tłumacz:')]{SIBLINGS}/a/text()" DETAILS = "//div[@id='book-details']" PUBLISH_DATE = "//dt[contains(@title,'Data pierwszego wydania" FIRST_PUBLISH_DATE = f"{DETAILS}{PUBLISH_DATE} oryginalnego')]{SIBLINGS}[1]/text()" FIRST_PUBLISH_DATE_PL = f"{DETAILS}{PUBLISH_DATE} polskiego')]{SIBLINGS}[1]/text()" - TAGS = "//nav[@aria-label='breadcrumbs']//a[contains(@href,'/ksiazki/k/')]/span/text()" + TAGS = "//a[contains(@href,'/ksiazki/t/')]/text()" # "//nav[@aria-label='breadcrumbs']//a[contains(@href,'/ksiazki/k/')]/span/text()" + RATING = "//meta[@property='books:rating:value']/@content" COVER = "//meta[@property='og:image']/@content" @@ -158,6 +160,7 @@ class LubimyCzytac(Metadata): class LubimyCzytacParser: PAGES_TEMPLATE = "

Książka ma {0} stron(y).

" + TRANSLATOR_TEMPLATE = "

Tłumacz: {0}

" PUBLISH_DATE_TEMPLATE = "

Data pierwszego wydania: {0}

" PUBLISH_DATE_PL_TEMPLATE = ( "

Data pierwszego wydania w Polsce: {0}

" @@ -346,5 +349,9 @@ class LubimyCzytacParser: description += LubimyCzytacParser.PUBLISH_DATE_PL_TEMPLATE.format( first_publish_date_pl.strftime("%d.%m.%Y") ) + translator = self._parse_xpath_node(xpath=LubimyCzytac.TRANSLATOR) + if translator: + description += LubimyCzytacParser.TRANSLATOR_TEMPLATE.format(translator) + return description From 894fd9d30afd30309c07daff841d8083d3efe81b Mon Sep 17 00:00:00 2001 From: Ozzie Isaacs Date: Sat, 11 May 2024 18:21:03 +0200 Subject: [PATCH 2/2] get rid of apscheduler timezone warning --- cps/schedule.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cps/schedule.py b/cps/schedule.py index bf622b36..21c8d32a 100644 --- a/cps/schedule.py +++ b/cps/schedule.py @@ -69,9 +69,12 @@ def register_scheduled_tasks(reconnect=True): duration = config.schedule_duration # Register scheduled tasks - scheduler.schedule_tasks(tasks=get_scheduled_tasks(reconnect), trigger=CronTrigger(hour=start)) + timezone_info = datetime.datetime.now(datetime.timezone.utc).astimezone().tzinfo + scheduler.schedule_tasks(tasks=get_scheduled_tasks(reconnect), trigger=CronTrigger(hour=start, + timezone=timezone_info)) end_time = calclulate_end_time(start, duration) - scheduler.schedule(func=end_scheduled_tasks, trigger=CronTrigger(hour=end_time.hour, minute=end_time.minute), + scheduler.schedule(func=end_scheduled_tasks, trigger=CronTrigger(hour=end_time.hour, minute=end_time.minute, + timezone=timezone_info), name="end scheduled task") # Kick-off tasks, if they should currently be running