Add detailed logging to debug TMDB API fallback issues
- Enhanced _get_digital_release_date with comprehensive logging - Added external clients configuration check in debug endpoint - Will show if TMDB API key is configured and external clients initialized - Added error handling for external client calls
This commit is contained in:
+36
-8
@@ -597,14 +597,27 @@ class MovieProcessor:
|
|||||||
|
|
||||||
def _get_digital_release_date(self, imdb_id: str) -> Tuple[Optional[str], str]:
|
def _get_digital_release_date(self, imdb_id: str) -> Tuple[Optional[str], str]:
|
||||||
"""Get release date from external sources using configured priority"""
|
"""Get release date from external sources using configured priority"""
|
||||||
release_result = self.external_clients.get_release_date_by_priority(
|
_log("INFO", f"🔍 Calling external clients for {imdb_id}")
|
||||||
imdb_id,
|
_log("INFO", f"Release date priority: {config.release_date_priority}")
|
||||||
config.release_date_priority,
|
_log("INFO", f"Smart validation enabled: {config.enable_smart_date_validation}")
|
||||||
enable_smart_validation=config.enable_smart_date_validation
|
|
||||||
)
|
try:
|
||||||
if release_result:
|
release_result = self.external_clients.get_release_date_by_priority(
|
||||||
return release_result[0], release_result[1]
|
imdb_id,
|
||||||
return None, "release:none"
|
config.release_date_priority,
|
||||||
|
enable_smart_validation=config.enable_smart_date_validation
|
||||||
|
)
|
||||||
|
_log("INFO", f"External clients result for {imdb_id}: {release_result}")
|
||||||
|
|
||||||
|
if release_result:
|
||||||
|
_log("INFO", f"✅ Got release date: {release_result[0]} from {release_result[1]}")
|
||||||
|
return release_result[0], release_result[1]
|
||||||
|
else:
|
||||||
|
_log("WARNING", f"❌ No release date found from external clients for {imdb_id}")
|
||||||
|
return None, "release:none"
|
||||||
|
except Exception as e:
|
||||||
|
_log("ERROR", f"External clients error for {imdb_id}: {e}")
|
||||||
|
return None, f"release:error:{str(e)}"
|
||||||
|
|
||||||
def _get_file_mtime_date(self, movie_path: Path) -> Tuple[str, str, Optional[str]]:
|
def _get_file_mtime_date(self, movie_path: Path) -> Tuple[str, str, Optional[str]]:
|
||||||
"""Get date from file modification time as last resort"""
|
"""Get date from file modification time as last resort"""
|
||||||
@@ -1046,6 +1059,21 @@ async def debug_movie_import_date(imdb_id: str):
|
|||||||
# Use the global movie processor instance to test full decision logic
|
# Use the global movie processor instance to test full decision logic
|
||||||
global movie_processor
|
global movie_processor
|
||||||
if movie_processor:
|
if movie_processor:
|
||||||
|
# First check external clients configuration
|
||||||
|
_log("INFO", f"=== CHECKING EXTERNAL CLIENTS CONFIG ===")
|
||||||
|
try:
|
||||||
|
tmdb_key = os.environ.get("TMDB_API_KEY", "")
|
||||||
|
_log("INFO", f"TMDB API Key configured: {'✅ YES' if tmdb_key else '❌ NO'}")
|
||||||
|
if tmdb_key:
|
||||||
|
_log("INFO", f"TMDB API Key length: {len(tmdb_key)} chars")
|
||||||
|
|
||||||
|
# Check if external clients exist
|
||||||
|
external_clients_available = hasattr(movie_processor, 'external_clients') and movie_processor.external_clients
|
||||||
|
_log("INFO", f"External clients initialized: {'✅ YES' if external_clients_available else '❌ NO'}")
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
_log("ERROR", f"Error checking external clients config: {e}")
|
||||||
|
|
||||||
# Test the full decision logic (including TMDB fallback)
|
# Test the full decision logic (including TMDB fallback)
|
||||||
final_date, final_source, released = movie_processor._decide_movie_dates(
|
final_date, final_source, released = movie_processor._decide_movie_dates(
|
||||||
imdb_id, dummy_path, should_query=True, existing=None
|
imdb_id, dummy_path, should_query=True, existing=None
|
||||||
|
|||||||
Reference in New Issue
Block a user