Skip to content

Commit

Permalink
fix: correct Prowlarr capabilities (#879)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Nov 13, 2024
1 parent 4b726e5 commit f2636e4
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions src/program/services/scrapers/prowlarr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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}")
logger.debug(f"TV search not available for {indexer.title}")

0 comments on commit f2636e4

Please sign in to comment.