web:updates again
Local Docker Build (Dev) / build-dev (push) Successful in 4s

This commit is contained in:
2025-10-15 10:57:24 -04:00
parent ecc70812af
commit 068507adce
2 changed files with 82 additions and 29 deletions
+1 -1
View File
@@ -1 +1 @@
2.2.6 2.2.7
+55 -2
View File
@@ -842,19 +842,44 @@ async def get_episode_date_options(dependencies: dict, imdb_id: str, season: int
# Check Sonarr for import dates # Check Sonarr for import dates
if tv_processor.sonarr and tv_processor.sonarr.enabled: if tv_processor.sonarr and tv_processor.sonarr.enabled:
try: try:
print(f"🔍 DEBUG: Attempting Sonarr lookup for {imdb_id}")
# Look up the series and episode in Sonarr # Look up the series and episode in Sonarr
series_data = tv_processor.sonarr.series_by_imdb(imdb_id) series_data = tv_processor.sonarr.series_by_imdb(imdb_id)
# If IMDb lookup fails, try direct series lookup as fallback
if not series_data:
print(f"🔍 DEBUG: IMDb lookup failed, trying direct series lookup")
try:
series_data = tv_processor.sonarr.series_by_imdb_direct(imdb_id)
except Exception as e:
print(f"⚠️ Direct series lookup also failed: {e}")
print(f"🔍 DEBUG: Series data found: {series_data is not None}")
if series_data: if series_data:
series_id = series_data.get('id') series_id = series_data.get('id')
series_title = series_data.get('title', 'Unknown')
print(f"🔍 DEBUG: Found series '{series_title}' with ID {series_id}")
if series_id: if series_id:
# Get episodes for the series # Get episodes for the series
print(f"🔍 DEBUG: Getting episodes for series {series_id}")
episodes = tv_processor.sonarr.episodes_for_series(series_id) episodes = tv_processor.sonarr.episodes_for_series(series_id)
print(f"🔍 DEBUG: Found {len(episodes)} episodes")
for ep in episodes: for ep in episodes:
if ep.get('seasonNumber') == season and ep.get('episodeNumber') == episode: ep_season = ep.get('seasonNumber')
ep_episode = ep.get('episodeNumber')
if ep_season == season and ep_episode == episode:
episode_id = ep.get('id') episode_id = ep.get('id')
ep_title = ep.get('title', 'Unknown')
print(f"🔍 DEBUG: Found target episode '{ep_title}' with ID {episode_id}")
if episode_id: if episode_id:
# Get import history for this specific episode # Get import history for this specific episode
print(f"🔍 DEBUG: Getting import history for episode {episode_id}")
import_date = tv_processor.sonarr.get_episode_import_history(episode_id) import_date = tv_processor.sonarr.get_episode_import_history(episode_id)
print(f"🔍 DEBUG: Import date found: {import_date}")
if import_date: if import_date:
# Check if this is different from current date # Check if this is different from current date
current_dateadded = episode_data.get('dateadded', '') current_dateadded = episode_data.get('dateadded', '')
@@ -866,23 +891,43 @@ async def get_episode_date_options(dependencies: dict, imdb_id: str, season: int
"source": "sonarr:import_history", "source": "sonarr:import_history",
"description": f"Import date from Sonarr: {import_date[:10]}" "description": f"Import date from Sonarr: {import_date[:10]}"
}) })
print(f"✅ Added Sonarr import option: {import_date[:10]}")
break break
else:
print(f"❌ No series found in Sonarr for {imdb_id}")
except Exception as e: except Exception as e:
print(f"⚠️ Failed to get Sonarr import date for {imdb_id} S{season:02d}E{episode:02d}: {e}") print(f"⚠️ Failed to get Sonarr import date for {imdb_id} S{season:02d}E{episode:02d}: {e}")
import traceback
print(f" Traceback: {traceback.format_exc()}")
# Check TMDB for episode air dates # Check TMDB for episode air dates
if external_clients.tmdb.enabled: if external_clients.tmdb.enabled:
try: try:
print(f"🔍 DEBUG: Attempting TMDB lookup for {imdb_id}")
# Get TMDB TV series ID from IMDb ID using find endpoint # Get TMDB TV series ID from IMDb ID using find endpoint
tv_find_result = external_clients.tmdb._get(f"/find/{imdb_id}", {"external_source": "imdb_id"}) tv_find_result = external_clients.tmdb._get(f"/find/{imdb_id}", {"external_source": "imdb_id"})
print(f"🔍 DEBUG: TMDB find result: {tv_find_result is not None}")
if tv_find_result and tv_find_result.get("tv_results"): if tv_find_result and tv_find_result.get("tv_results"):
tv_show = tv_find_result["tv_results"][0] tv_results = tv_find_result.get("tv_results", [])
print(f"🔍 DEBUG: Found {len(tv_results)} TV results")
if tv_results:
tv_show = tv_results[0]
tmdb_id = tv_show.get("id") tmdb_id = tv_show.get("id")
tv_title = tv_show.get("name", "Unknown")
print(f"🔍 DEBUG: Found TMDB series '{tv_title}' with ID {tmdb_id}")
if tmdb_id: if tmdb_id:
# Get episode air date from TMDB # Get episode air date from TMDB
print(f"🔍 DEBUG: Getting TMDB season {season} episodes for series {tmdb_id}")
episodes = external_clients.tmdb.get_tv_season_episodes(tmdb_id, season) episodes = external_clients.tmdb.get_tv_season_episodes(tmdb_id, season)
print(f"🔍 DEBUG: TMDB episodes found: {episodes}")
if episode in episodes: if episode in episodes:
air_date = episodes[episode] air_date = episodes[episode]
print(f"🔍 DEBUG: TMDB air date for S{season:02d}E{episode:02d}: {air_date}")
if air_date: if air_date:
# Check if this is different from current aired date # Check if this is different from current aired date
current_aired = episode_data.get('aired', '') current_aired = episode_data.get('aired', '')
@@ -894,6 +939,7 @@ async def get_episode_date_options(dependencies: dict, imdb_id: str, season: int
"source": "tmdb:airdate", "source": "tmdb:airdate",
"description": f"Air date from TMDB: {air_date}" "description": f"Air date from TMDB: {air_date}"
}) })
print(f"✅ Added TMDB air date option: {air_date}")
# If no aired date in database, also add this as "Use Air Date" option # If no aired date in database, also add this as "Use Air Date" option
if not current_aired: if not current_aired:
@@ -904,8 +950,15 @@ async def get_episode_date_options(dependencies: dict, imdb_id: str, season: int
"source": "airdate", "source": "airdate",
"description": f"Use air date from TMDB: {air_date}" "description": f"Use air date from TMDB: {air_date}"
}) })
print(f"✅ Added 'Use Air Date' option from TMDB: {air_date}")
else:
print(f"❌ Episode {episode} not found in TMDB season {season} data")
else:
print(f"❌ No TV results found in TMDB for {imdb_id}")
except Exception as e: except Exception as e:
print(f"⚠️ Failed to get TMDB air date for {imdb_id} S{season:02d}E{episode:02d}: {e}") print(f"⚠️ Failed to get TMDB air date for {imdb_id} S{season:02d}E{episode:02d}: {e}")
import traceback
print(f" Traceback: {traceback.format_exc()}")
# Check external clients for episode air dates (TVDB, OMDb) # Check external clients for episode air dates (TVDB, OMDb)
if hasattr(external_clients, 'get_episode_air_date'): if hasattr(external_clients, 'get_episode_air_date'):