From f2636e408f66a730915cfb2f49f56e38b1faf8c9 Mon Sep 17 00:00:00 2001 From: Dustin Miller <1342542+spdustin@users.noreply.github.com> Date: Wed, 13 Nov 2024 10:26:29 -0600 Subject: [PATCH] fix: correct Prowlarr capabilities (#879) * fix: correct Prowlarr capabilities The current `_get_indexer_from_json()` private method only stores the first character of an indexer's `movieSearchParams`/`tvSearchParams`, resulting in Riven only providing the show/movie name to Prowlarr indexers even if they're able to search by year/season/episode. This commit fixes the issue by removing the 0-slice from the list comprehension. * Update src/program/services/scrapers/prowlarr.py Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --------- Co-authored-by: Gaisberg <93206976+Gaisberg@users.noreply.github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- src/program/services/scrapers/prowlarr.py | 29 +++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/program/services/scrapers/prowlarr.py b/src/program/services/scrapers/prowlarr.py index 31707056..fc57b8e3 100644 --- a/src/program/services/scrapers/prowlarr.py +++ b/src/program/services/scrapers/prowlarr.py @@ -218,7 +218,32 @@ def _get_indexer_from_json(self, json_content: str) -> list[ProwlarrIndexer]: """Parse the indexers from the XML content""" indexer_list = [] for indexer in json.loads(json_content): - indexer_list.append(ProwlarrIndexer(title=indexer["name"], id=str(indexer["id"]), link=indexer["infoLink"], type=indexer["protocol"], language=indexer["language"], movie_search_capabilities=(s[0] for s in indexer["capabilities"]["movieSearchParams"]) if len([s for s in indexer["capabilities"]["categories"] if s["name"] == "Movies"]) > 0 else None, tv_search_capabilities=(s[0] for s in indexer["capabilities"]["tvSearchParams"]) if len([s for s in indexer["capabilities"]["categories"] if s["name"] == "TV"]) > 0 else None)) + has_movies = any( + category["name"] == "Movies" + for category in indexer["capabilities"]["categories"] + ) + has_tv = any( + category["name"] == "TV" + for category in indexer["capabilities"]["categories"] + ) + + indexer_list.append( + ProwlarrIndexer( + title=indexer["name"], + id=str(indexer["id"]), + link=indexer["infoLink"], + type=indexer["protocol"], + language=indexer["language"], + movie_search_capabilities=( + list(indexer["capabilities"]["movieSearchParams"]) + if has_movies else None + ), + tv_search_capabilities=( + list(indexer["capabilities"]["tvSearchParams"]) + if has_tv else None + ) + ) + ) return indexer_list @@ -262,4 +287,4 @@ def _log_indexers(self) -> None: if not indexer.movie_search_capabilities: logger.debug(f"Movie search not available for {indexer.title}") if not indexer.tv_search_capabilities: - logger.debug(f"TV search not available for {indexer.title}") \ No newline at end of file + logger.debug(f"TV search not available for {indexer.title}")