diff --git a/api/web_routes.py b/api/web_routes.py index 6990bb7..e1f9db5 100644 --- a/api/web_routes.py +++ b/api/web_routes.py @@ -581,11 +581,25 @@ async def update_episode_date(dependencies: dict, imdb_id: str, season: int, epi """Update dateadded for a specific episode""" db = dependencies["db"] + print(f"🔍 DEBUG: update_episode_date called with dateadded={repr(dateadded)}, source={repr(source)}") + # Get existing episode episode_data = db.get_episode_date(imdb_id, season, episode) if not episode_data: raise HTTPException(status_code=404, detail="Episode not found") + # Handle special sources + if source == "airdate" and episode_data.get('aired'): + # Use aired date as dateadded for airdate source + aired_date = episode_data.get('aired') + if hasattr(aired_date, 'isoformat'): + dateadded = aired_date.isoformat() + "T20:00:00" # Set to 8 PM on air date + else: + dateadded = str(aired_date) + "T20:00:00" + print(f"🔍 DEBUG: Using air date as dateadded: {dateadded}") + + print(f"🔍 DEBUG: Final dateadded value: {repr(dateadded)}") + # Update the date db.upsert_episode_date( imdb_id=imdb_id,