From fc9a9cb9ac3c83826ed0cc38391a110df83b9328 Mon Sep 17 00:00:00 2001 From: Ozzie Isaacs Date: Sat, 11 May 2024 09:03:22 +0200 Subject: [PATCH] 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