mirror of
https://github.com/maxdorninger/MediaManager.git
synced 2026-04-17 15:13:24 +02:00
refactor indexer service: streamline movie and season search methods
This commit is contained in:
@@ -231,29 +231,24 @@ class MovieService:
|
||||
log.debug(f"getting all available torrents for movie {movie_id}")
|
||||
movie = self.movie_repository.get_movie_by_id(movie_id=movie_id)
|
||||
if search_query_override:
|
||||
search_query = search_query_override
|
||||
else:
|
||||
search_query = f"{movie.name}"
|
||||
|
||||
torrents: list[IndexerQueryResult] = self.indexer_service.search(
|
||||
query=search_query, is_tv=False
|
||||
)
|
||||
|
||||
if search_query_override:
|
||||
log.debug(f"Found with search query override {torrents.__len__()} torrents")
|
||||
torrents = self.indexer_service.search(
|
||||
query=search_query_override, is_tv=False
|
||||
)
|
||||
return torrents
|
||||
else:
|
||||
torrents = self.indexer_service.search_movie(movie=movie)
|
||||
|
||||
result: list[IndexerQueryResult] = []
|
||||
for torrent in torrents:
|
||||
if (
|
||||
movie.name.lower() in torrent.title.lower()
|
||||
and str(movie.year) in torrent.title
|
||||
):
|
||||
result.append(torrent)
|
||||
results: list[IndexerQueryResult] = []
|
||||
for torrent in torrents:
|
||||
if (
|
||||
movie.name.lower() in torrent.title.lower()
|
||||
and str(movie.year) in torrent.title
|
||||
):
|
||||
results.append(torrent)
|
||||
|
||||
return evaluate_indexer_query_results(
|
||||
is_tv=False, query_results=result, media=movie
|
||||
)
|
||||
return evaluate_indexer_query_results(
|
||||
is_tv=False, query_results=results, media=movie
|
||||
)
|
||||
|
||||
def get_all_movies(self) -> list[Movie]:
|
||||
"""
|
||||
|
||||
@@ -244,27 +244,25 @@ class TvService:
|
||||
:return: A list of indexer query results.
|
||||
"""
|
||||
show = self.tv_repository.get_show_by_id(show_id=show_id)
|
||||
if search_query_override:
|
||||
search_query = search_query_override
|
||||
else:
|
||||
# TODO: add more Search query strings and combine all the results, like "season 3", "s03", "s3"
|
||||
search_query = show.name + " s" + str(season_number).zfill(2)
|
||||
|
||||
torrents: list[IndexerQueryResult] = self.indexer_service.search(
|
||||
query=search_query, is_tv=True
|
||||
)
|
||||
|
||||
if search_query_override:
|
||||
torrents = self.indexer_service.search(
|
||||
query=search_query_override, is_tv=True
|
||||
)
|
||||
return torrents
|
||||
else:
|
||||
torrents = self.indexer_service.search_season(
|
||||
show=show, season_number=season_number
|
||||
)
|
||||
|
||||
result: list[IndexerQueryResult] = []
|
||||
for torrent in torrents:
|
||||
if season_number in torrent.season:
|
||||
result.append(torrent)
|
||||
results: list[IndexerQueryResult] = []
|
||||
for torrent in torrents:
|
||||
if season_number in torrent.season:
|
||||
results.append(torrent)
|
||||
|
||||
return evaluate_indexer_query_results(
|
||||
is_tv=True, query_results=result, media=show
|
||||
)
|
||||
return evaluate_indexer_query_results(
|
||||
is_tv=True, query_results=results, media=show
|
||||
)
|
||||
|
||||
def get_all_shows(self) -> list[Show]:
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user