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}")