This commit is contained in:
+76
-33
@@ -860,7 +860,33 @@ async def get_episode_date_options(dependencies: dict, imdb_id: str, season: int
|
|||||||
for ls in lincoln_series:
|
for ls in lincoln_series:
|
||||||
print(f" - Title: '{ls.get('title')}', IMDb: '{ls.get('imdbId')}', ID: {ls.get('id')}")
|
print(f" - Title: '{ls.get('title')}', IMDb: '{ls.get('imdbId')}', ID: {ls.get('id')}")
|
||||||
|
|
||||||
|
# Try direct lookup first
|
||||||
series_data = tv_processor.sonarr.series_by_imdb_direct(imdb_id)
|
series_data = tv_processor.sonarr.series_by_imdb_direct(imdb_id)
|
||||||
|
|
||||||
|
# If still no match but we found Lincoln Lawyer series, try fuzzy matching
|
||||||
|
if not series_data and lincoln_series:
|
||||||
|
target_imdb_num = imdb_id.replace('tt', '').lower()
|
||||||
|
print(f"🔍 DEBUG: Trying fuzzy match for IMDb number: {target_imdb_num}")
|
||||||
|
|
||||||
|
for ls in lincoln_series:
|
||||||
|
ls_imdb = ls.get('imdbId', '')
|
||||||
|
ls_imdb_num = ls_imdb.replace('tt', '').lower()
|
||||||
|
print(f" - Comparing {target_imdb_num} vs {ls_imdb_num}")
|
||||||
|
|
||||||
|
# Check if IMDb numbers are close (within 10 digits)
|
||||||
|
if ls_imdb_num and target_imdb_num:
|
||||||
|
try:
|
||||||
|
target_num = int(target_imdb_num)
|
||||||
|
ls_num = int(ls_imdb_num)
|
||||||
|
diff = abs(target_num - ls_num)
|
||||||
|
print(f" - Numeric difference: {diff}")
|
||||||
|
|
||||||
|
if diff <= 10: # Allow small IMDb ID differences
|
||||||
|
print(f"✅ Found close IMDb match: {ls_imdb} vs {imdb_id} (diff: {diff})")
|
||||||
|
series_data = ls
|
||||||
|
break
|
||||||
|
except ValueError:
|
||||||
|
continue
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"⚠️ Direct series lookup also failed: {e}")
|
print(f"⚠️ Direct series lookup also failed: {e}")
|
||||||
import traceback
|
import traceback
|
||||||
@@ -921,6 +947,10 @@ async def get_episode_date_options(dependencies: dict, imdb_id: str, season: int
|
|||||||
print(f"🔍 DEBUG: TMDB find result: {tv_find_result is not None}")
|
print(f"🔍 DEBUG: TMDB find result: {tv_find_result is not None}")
|
||||||
print(f"🔍 DEBUG: TMDB raw response: {tv_find_result}")
|
print(f"🔍 DEBUG: TMDB raw response: {tv_find_result}")
|
||||||
|
|
||||||
|
# Check both tv_results and tv_episode_results
|
||||||
|
tmdb_id = None
|
||||||
|
tv_title = "Unknown"
|
||||||
|
|
||||||
if tv_find_result and tv_find_result.get("tv_results"):
|
if tv_find_result and tv_find_result.get("tv_results"):
|
||||||
tv_results = tv_find_result.get("tv_results", [])
|
tv_results = tv_find_result.get("tv_results", [])
|
||||||
print(f"🔍 DEBUG: Found {len(tv_results)} TV results")
|
print(f"🔍 DEBUG: Found {len(tv_results)} TV results")
|
||||||
@@ -931,43 +961,56 @@ async def get_episode_date_options(dependencies: dict, imdb_id: str, season: int
|
|||||||
tv_title = tv_show.get("name", "Unknown")
|
tv_title = tv_show.get("name", "Unknown")
|
||||||
print(f"🔍 DEBUG: Found TMDB series '{tv_title}' with ID {tmdb_id}")
|
print(f"🔍 DEBUG: Found TMDB series '{tv_title}' with ID {tmdb_id}")
|
||||||
|
|
||||||
if tmdb_id:
|
# Fallback: Check tv_episode_results for show_id
|
||||||
# Get episode air date from TMDB
|
elif tv_find_result and tv_find_result.get("tv_episode_results"):
|
||||||
print(f"🔍 DEBUG: Getting TMDB season {season} episodes for series {tmdb_id}")
|
episode_results = tv_find_result.get("tv_episode_results", [])
|
||||||
episodes = external_clients.tmdb.get_tv_season_episodes(tmdb_id, season)
|
print(f"🔍 DEBUG: Found {len(episode_results)} TV episode results")
|
||||||
print(f"🔍 DEBUG: TMDB episodes found: {episodes}")
|
|
||||||
|
|
||||||
if episode in episodes:
|
if episode_results:
|
||||||
air_date = episodes[episode]
|
episode = episode_results[0]
|
||||||
print(f"🔍 DEBUG: TMDB air date for S{season:02d}E{episode:02d}: {air_date}")
|
tmdb_id = episode.get("show_id")
|
||||||
|
episode_name = episode.get("name", "Unknown")
|
||||||
|
print(f"🔍 DEBUG: Found TMDB series via episode '{episode_name}' with show_id {tmdb_id}")
|
||||||
|
|
||||||
if air_date:
|
if tmdb_id:
|
||||||
# Check if this is different from current aired date
|
print(f"🔍 DEBUG: Using TMDB ID {tmdb_id} for series lookup")
|
||||||
current_aired = episode_data.get('aired', '')
|
|
||||||
if not current_aired or current_aired != air_date:
|
|
||||||
options.append({
|
|
||||||
"type": "tmdb_air",
|
|
||||||
"label": "TMDB Air Date",
|
|
||||||
"date": f"{air_date}T20:00:00", # Default to 8 PM
|
|
||||||
"source": "tmdb:airdate",
|
|
||||||
"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
|
# Get episode air date from TMDB
|
||||||
if not current_aired:
|
print(f"🔍 DEBUG: Getting TMDB season {season} episodes for series {tmdb_id}")
|
||||||
options.insert(1, { # Insert after current option
|
episodes = external_clients.tmdb.get_tv_season_episodes(tmdb_id, season)
|
||||||
"type": "airdate_tmdb",
|
print(f"🔍 DEBUG: TMDB episodes found: {episodes}")
|
||||||
"label": "Use Air Date (TMDB)",
|
|
||||||
"date": f"{air_date}T20:00:00",
|
if episode in episodes:
|
||||||
"source": "airdate",
|
air_date = episodes[episode]
|
||||||
"description": f"Use air date from TMDB: {air_date}"
|
print(f"🔍 DEBUG: TMDB air date for S{season:02d}E{episode:02d}: {air_date}")
|
||||||
})
|
|
||||||
print(f"✅ Added 'Use Air Date' option from TMDB: {air_date}")
|
if air_date:
|
||||||
else:
|
# Check if this is different from current aired date
|
||||||
print(f"❌ Episode {episode} not found in TMDB season {season} data")
|
current_aired = episode_data.get('aired', '')
|
||||||
|
if not current_aired or current_aired != air_date:
|
||||||
|
options.append({
|
||||||
|
"type": "tmdb_air",
|
||||||
|
"label": "TMDB Air Date",
|
||||||
|
"date": f"{air_date}T20:00:00", # Default to 8 PM
|
||||||
|
"source": "tmdb:airdate",
|
||||||
|
"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 not current_aired:
|
||||||
|
options.insert(1, { # Insert after current option
|
||||||
|
"type": "airdate_tmdb",
|
||||||
|
"label": "Use Air Date (TMDB)",
|
||||||
|
"date": f"{air_date}T20:00:00",
|
||||||
|
"source": "airdate",
|
||||||
|
"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:
|
else:
|
||||||
print(f"❌ No TV results found in TMDB for {imdb_id}")
|
print(f"❌ No TV series ID 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
|
import traceback
|
||||||
|
|||||||
Reference in New Issue
Block a user