diff --git a/list_sync/main.py b/list_sync/main.py index 830178e..0b1bc81 100644 --- a/list_sync/main.py +++ b/list_sync/main.py @@ -538,10 +538,11 @@ def process_media_item(item: Dict[str, Any], overseerr_client: OverseerrClient, try: # Import Trakt search functions - from .providers.trakt import search_trakt_by_imdb_id, search_trakt_by_title - + from .providers.trakt import search_trakt_by_imdb_id, search_trakt_by_title, is_trakt_configured + search_result = None match_method = None + trakt_configured = is_trakt_configured() # METHOD 1: Direct TMDB ID lookup (fastest, most reliable) if tmdb_id: @@ -560,7 +561,9 @@ def process_media_item(item: Dict[str, Any], overseerr_client: OverseerrClient, logging.info(f"✅ SUCCESS: Direct TMDB ID lookup") # METHOD 2: IMDB ID → Trakt → TMDB ID - if not search_result and imdb_id: + if not search_result and imdb_id and not trakt_configured: + logging.info("⏭️ METHOD 2 skipped: Trakt not configured (no TRAKT_CLIENT_ID)") + elif not search_result and imdb_id: logging.info(f"🔍 METHOD 2: IMDB ID → Trakt → TMDB ID (IMDB: {imdb_id})") trakt_result = search_trakt_by_imdb_id(imdb_id) if trakt_result and trakt_result.get('tmdb_id'): @@ -584,7 +587,9 @@ def process_media_item(item: Dict[str, Any], overseerr_client: OverseerrClient, logging.info(f"⚠️ WARNING: Trakt could not resolve IMDB ID {imdb_id} to TMDB ID") # METHOD 3: Title/Year → Trakt → TMDB ID - if not search_result: + if not search_result and not trakt_configured: + logging.info("⏭️ METHOD 3 skipped: Trakt not configured (no TRAKT_CLIENT_ID)") + elif not search_result: logging.info(f"🔍 METHOD 3: Title/Year → Trakt → TMDB ID") trakt_result = search_trakt_by_title(search_title, year, media_type) if trakt_result and trakt_result.get('tmdb_id'): diff --git a/list_sync/providers/trakt.py b/list_sync/providers/trakt.py index 084f27c..092de04 100644 --- a/list_sync/providers/trakt.py +++ b/list_sync/providers/trakt.py @@ -66,6 +66,25 @@ def get_trakt_client_id() -> str: ) +def is_trakt_configured() -> bool: + """ + Check whether a Trakt Client ID is configured, without raising. + + Used to skip Trakt-dependent lookup methods (IMDB->TMDB, Title->TMDB) + entirely when Trakt isn't set up, instead of attempting a network call + that's guaranteed to fail. This also avoids tripping Trakt's rate + limiter on every single processed item when Trakt is simply unused. + + Returns: + bool: True if a Trakt Client ID is available from config or env. + """ + try: + get_trakt_client_id() + return True + except ValueError: + return False + + def get_trakt_special_items_limit() -> int: """ Get the items limit for special Trakt lists.