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):
|
async def get_episode_date_options(dependencies: dict, imdb_id: str, season: int, episode: int):
|
||||||
"""Get available date options for an episode"""
|
"""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: 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"]
|
db = dependencies["db"]
|
||||||
|
|
||||||
# Validate parameters with enhanced checking
|
# 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")
|
print(f"🔍 DEBUG: Found {len(episode_results)} TV episode results")
|
||||||
|
|
||||||
if episode_results:
|
if episode_results:
|
||||||
episode = episode_results[0]
|
tmdb_episode_data = episode_results[0]
|
||||||
tmdb_id = episode.get("show_id")
|
tmdb_id = tmdb_episode_data.get("show_id")
|
||||||
episode_name = episode.get("name", "Unknown")
|
episode_name = tmdb_episode_data.get("name", "Unknown")
|
||||||
print(f"🔍 DEBUG: Found TMDB series via episode '{episode_name}' with show_id {tmdb_id}")
|
print(f"🔍 DEBUG: Found TMDB series via episode '{episode_name}' with show_id {tmdb_id}")
|
||||||
|
|
||||||
if 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)
|
episodes = external_clients.tmdb.get_tv_season_episodes(tmdb_id, season)
|
||||||
print(f"🔍 DEBUG: TMDB episodes found: {episodes}")
|
print(f"🔍 DEBUG: TMDB episodes found: {episodes}")
|
||||||
|
|
||||||
try:
|
if episode in episodes:
|
||||||
episode_num = int(episode)
|
air_date = episodes[episode]
|
||||||
except (ValueError, TypeError) as conv_error:
|
print(f"🔍 DEBUG: TMDB air date for S{season:02d}E{episode:02d}: {air_date}")
|
||||||
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 air_date:
|
if air_date:
|
||||||
# Check if this is different from current aired 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}")
|
print(f"✅ Added 'Use Air Date' option from TMDB: {air_date}")
|
||||||
else:
|
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:
|
else:
|
||||||
print(f"❌ No TV series ID 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:
|
||||||
try:
|
print(f"⚠️ Failed to get TMDB air date for {imdb_id} S{season:02d}E{episode:02d}: {e}")
|
||||||
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}")
|
|
||||||
import traceback
|
import traceback
|
||||||
print(f" Traceback: {traceback.format_exc()}")
|
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}"
|
"description": f"Use air date from external sources: {air_date}"
|
||||||
})
|
})
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
try:
|
print(f"⚠️ Failed to get external air date for {imdb_id} S{season:02d}E{episode:02d}: {e}")
|
||||||
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}")
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
try:
|
print(f"⚠️ External source lookup failed for {imdb_id} S{season:02d}E{episode:02d}: {e}")
|
||||||
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}")
|
|
||||||
|
|
||||||
# Option 4: Manual entry
|
# Option 4: Manual entry
|
||||||
options.append({
|
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"
|
"description": "Enter custom date and time"
|
||||||
})
|
})
|
||||||
|
|
||||||
# Safe format string for episode
|
print(f"🔍 DEBUG: Generated {len(options)} options for {imdb_id} S{season:02d}E{episode:02d}:")
|
||||||
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)")
|
|
||||||
|
|
||||||
for i, option in enumerate(options):
|
for i, option in enumerate(options):
|
||||||
print(f" Option {i}: {option}")
|
print(f" Option {i}: {option}")
|
||||||
|
|
||||||
# Ensure we always return valid JSON
|
print(f"🔍 DEBUG: Returning result with {len(options)} options")
|
||||||
try:
|
return {
|
||||||
# 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 = {
|
|
||||||
"imdb_id": imdb_id,
|
"imdb_id": imdb_id,
|
||||||
"season": season,
|
"season": season,
|
||||||
"episode": episode,
|
"episode": episode,
|
||||||
"current_data": episode_data,
|
"current_data": episode_data,
|
||||||
"options": options
|
"options": options
|
||||||
}
|
}
|
||||||
return result
|
|
||||||
Reference in New Issue
Block a user