From a63af5882ed9e97284dc81cc198e06267b68ca1a Mon Sep 17 00:00:00 2001 From: Ozzie Isaacs Date: Tue, 5 Apr 2022 19:04:42 +0200 Subject: [PATCH] Fix for #2363 (Handle empty response from lubimyczytac metadata provider) --- cps/metadata_provider/lubimyczytac.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/cps/metadata_provider/lubimyczytac.py b/cps/metadata_provider/lubimyczytac.py index 814a785e..90a6b2d8 100644 --- a/cps/metadata_provider/lubimyczytac.py +++ b/cps/metadata_provider/lubimyczytac.py @@ -113,17 +113,18 @@ class LubimyCzytac(Metadata): ) -> Optional[List[MetaRecord]]: if self.active: result = requests.get(self._prepare_query(title=query)) - root = fromstring(result.text) - lc_parser = LubimyCzytacParser(root=root, metadata=self) - matches = lc_parser.parse_search_results() - if matches: - with ThreadPool(processes=10) as pool: - final_matches = pool.starmap( - lc_parser.parse_single_book, - [(match, generic_cover, locale) for match in matches], - ) - return final_matches - return matches + if result.text: + root = fromstring(result.text) + lc_parser = LubimyCzytacParser(root=root, metadata=self) + matches = lc_parser.parse_search_results() + if matches: + with ThreadPool(processes=10) as pool: + final_matches = pool.starmap( + lc_parser.parse_single_book, + [(match, generic_cover, locale) for match in matches], + ) + return final_matches + return matches def _prepare_query(self, title: str) -> str: query = ""