From 123378ff351ed4b6df15f0a33c6d1227f6f91fc5 Mon Sep 17 00:00:00 2001 From: Goldy <153996346+g0ldyy@users.noreply.github.com> Date: Sun, 7 Jul 2024 14:23:02 +0200 Subject: [PATCH] feat: zilean only mode --- comet/api/stream.py | 40 +++++++++++++++++++++++----------------- comet/utils/models.py | 8 ++++---- 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/comet/api/stream.py b/comet/api/stream.py index 72114c3..124eb99 100644 --- a/comet/api/stream.py +++ b/comet/api/stream.py @@ -158,26 +158,32 @@ async def stream(request: Request, b64config: str, type: str, id: str): f"Start of {indexer_manager_type} search for {logName} with indexers {config['indexers']}" ) - search_terms = [name] - if type == "series": - search_terms.append(f"{name} S0{season}E0{episode}") - tasks = [ - get_indexer_manager(session, indexer_manager_type, config["indexers"], term) - for term in search_terms - ] - search_response = await asyncio.gather(*tasks) - torrents = [] - for results in search_response: - if results is None: - continue + if len(config["indexers"]) != 0: + search_terms = [name] + if type == "series": + search_terms.append(f"{name} S0{season}E0{episode}") + tasks = [ + get_indexer_manager(session, indexer_manager_type, config["indexers"], term) + for term in search_terms + ] + search_response = await asyncio.gather(*tasks) - for result in results: - torrents.append(result) + + for results in search_response: + if results is None: + continue - logger.info( - f"{len(torrents)} torrents found for {logName} with {indexer_manager_type}" - ) + for result in results: + torrents.append(result) + + logger.info( + f"{len(torrents)} torrents found for {logName} with {indexer_manager_type}" + ) + else: + logger.info( + f"No indexer selected by user for {logName}" + ) zilean_hashes_count = 0 if settings.ZILEAN_URL: diff --git a/comet/utils/models.py b/comet/utils/models.py index 87cbd39..b3caa50 100644 --- a/comet/utils/models.py +++ b/comet/utils/models.py @@ -48,10 +48,10 @@ def check_indexers(cls, v, values): valid_indexers = [ indexer for indexer in v if indexer in settings.INDEXER_MANAGER_INDEXERS ] - if not valid_indexers: - raise ValueError( - f"At least one indexer must be from {settings.INDEXER_MANAGER_INDEXERS}" - ) + # if not valid_indexers: # For only Zilean mode + # raise ValueError( + # f"At least one indexer must be from {settings.INDEXER_MANAGER_INDEXERS}" + # ) return valid_indexers @field_validator("maxResults")