This commit is contained in:
+13
-58
@@ -772,10 +772,6 @@ async def get_movie_date_options(dependencies: dict, imdb_id: str):
|
||||
async def get_episode_date_options(dependencies: dict, imdb_id: str, season: int, episode: int):
|
||||
"""Get available date options for an episode"""
|
||||
print(f"🔍 DEBUG: get_episode_date_options called with imdb_id={imdb_id}, season={season}, episode={episode}")
|
||||
print(f"🔍 DEBUG: episode type: {type(episode)}, episode value: {episode}")
|
||||
if isinstance(episode, dict):
|
||||
print(f"🔍 DEBUG: episode dict keys: {list(episode.keys()) if episode else 'None'}")
|
||||
print(f"🔍 DEBUG: episode dict values: {list(episode.values()) if episode else 'None'}")
|
||||
db = dependencies["db"]
|
||||
|
||||
# Validate parameters with enhanced checking
|
||||
@@ -971,9 +967,9 @@ async def get_episode_date_options(dependencies: dict, imdb_id: str, season: int
|
||||
print(f"🔍 DEBUG: Found {len(episode_results)} TV episode results")
|
||||
|
||||
if episode_results:
|
||||
episode = episode_results[0]
|
||||
tmdb_id = episode.get("show_id")
|
||||
episode_name = episode.get("name", "Unknown")
|
||||
tmdb_episode_data = episode_results[0]
|
||||
tmdb_id = tmdb_episode_data.get("show_id")
|
||||
episode_name = tmdb_episode_data.get("name", "Unknown")
|
||||
print(f"🔍 DEBUG: Found TMDB series via episode '{episode_name}' with show_id {tmdb_id}")
|
||||
|
||||
if tmdb_id:
|
||||
@@ -984,16 +980,9 @@ async def get_episode_date_options(dependencies: dict, imdb_id: str, season: int
|
||||
episodes = external_clients.tmdb.get_tv_season_episodes(tmdb_id, season)
|
||||
print(f"🔍 DEBUG: TMDB episodes found: {episodes}")
|
||||
|
||||
try:
|
||||
episode_num = int(episode)
|
||||
except (ValueError, TypeError) as conv_error:
|
||||
print(f"❌ Cannot convert episode to int: {episode} (type: {type(episode)})")
|
||||
print(f" Error: {conv_error}")
|
||||
episode_num = None
|
||||
|
||||
if episode_num and episode_num in episodes:
|
||||
air_date = episodes[episode_num]
|
||||
print(f"🔍 DEBUG: TMDB air date for S{season:02d}E{episode_num:02d}: {air_date}")
|
||||
if episode in episodes:
|
||||
air_date = episodes[episode]
|
||||
print(f"🔍 DEBUG: TMDB air date for S{season:02d}E{episode:02d}: {air_date}")
|
||||
|
||||
if air_date:
|
||||
# Check if this is different from current aired date
|
||||
@@ -1019,15 +1008,11 @@ async def get_episode_date_options(dependencies: dict, imdb_id: str, season: int
|
||||
})
|
||||
print(f"✅ Added 'Use Air Date' option from TMDB: {air_date}")
|
||||
else:
|
||||
print(f"❌ Episode {episode_num} not found in TMDB season {season} data")
|
||||
print(f"❌ Episode {episode} not found in TMDB season {season} data")
|
||||
else:
|
||||
print(f"❌ No TV series ID found in TMDB for {imdb_id}")
|
||||
except Exception as e:
|
||||
try:
|
||||
episode_num = int(episode) if not isinstance(episode, int) else episode
|
||||
print(f"⚠️ Failed to get TMDB air date for {imdb_id} S{season:02d}E{episode_num:02d}: {e}")
|
||||
except:
|
||||
print(f"⚠️ Failed to get TMDB air date for {imdb_id}: {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()}")
|
||||
|
||||
@@ -1057,18 +1042,10 @@ async def get_episode_date_options(dependencies: dict, imdb_id: str, season: int
|
||||
"description": f"Use air date from external sources: {air_date}"
|
||||
})
|
||||
except Exception as e:
|
||||
try:
|
||||
episode_num = int(episode) if not isinstance(episode, int) else episode
|
||||
print(f"⚠️ Failed to get external air date for {imdb_id} S{season:02d}E{episode_num:02d}: {e}")
|
||||
except:
|
||||
print(f"⚠️ Failed to get external air date for {imdb_id}: {e}")
|
||||
print(f"⚠️ Failed to get external air date for {imdb_id} S{season:02d}E{episode:02d}: {e}")
|
||||
|
||||
except Exception as e:
|
||||
try:
|
||||
episode_num = int(episode) if not isinstance(episode, int) else episode
|
||||
print(f"⚠️ External source lookup failed for {imdb_id} S{season:02d}E{episode_num:02d}: {e}")
|
||||
except:
|
||||
print(f"⚠️ External source lookup failed for {imdb_id}: {e}")
|
||||
print(f"⚠️ External source lookup failed for {imdb_id} S{season:02d}E{episode:02d}: {e}")
|
||||
|
||||
# Option 4: Manual entry
|
||||
options.append({
|
||||
@@ -1079,37 +1056,15 @@ async def get_episode_date_options(dependencies: dict, imdb_id: str, season: int
|
||||
"description": "Enter custom date and time"
|
||||
})
|
||||
|
||||
# Safe format string for episode
|
||||
try:
|
||||
episode_num = int(episode) if not isinstance(episode, int) else episode
|
||||
print(f"🔍 DEBUG: Generated {len(options)} options for {imdb_id} S{season:02d}E{episode_num:02d}:")
|
||||
except:
|
||||
print(f"🔍 DEBUG: Generated {len(options)} options for {imdb_id} (episode format error)")
|
||||
|
||||
print(f"🔍 DEBUG: Generated {len(options)} options for {imdb_id} S{season:02d}E{episode:02d}:")
|
||||
for i, option in enumerate(options):
|
||||
print(f" Option {i}: {option}")
|
||||
|
||||
# Ensure we always return valid JSON
|
||||
try:
|
||||
# Convert episode to int if it's not already
|
||||
episode_int = int(episode) if not isinstance(episode, int) else episode
|
||||
result = {
|
||||
"imdb_id": imdb_id,
|
||||
"season": season,
|
||||
"episode": episode_int,
|
||||
"current_data": episode_data,
|
||||
"options": options
|
||||
}
|
||||
print(f"🔍 DEBUG: Returning result with {len(result['options'])} options")
|
||||
return result
|
||||
except Exception as e:
|
||||
print(f"❌ ERROR: Failed to create response: {e}")
|
||||
# Return with original episode value if conversion fails
|
||||
result = {
|
||||
print(f"🔍 DEBUG: Returning result with {len(options)} options")
|
||||
return {
|
||||
"imdb_id": imdb_id,
|
||||
"season": season,
|
||||
"episode": episode,
|
||||
"current_data": episode_data,
|
||||
"options": options
|
||||
}
|
||||
return result
|
||||
Reference in New Issue
Block a user