diff --git a/VERSION b/VERSION index 0a69206..6cbacdc 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.0.10 +2.0.11 diff --git a/api/routes.py b/api/routes.py index ad7e582..a7df1db 100644 --- a/api/routes.py +++ b/api/routes.py @@ -72,13 +72,32 @@ async def sonarr_webhook(request: Request, background_tasks: BackgroundTasks, de print(f"ERROR: Could not find series directory: {series_title} ({imdb_id})") return {"status": "error", "reason": "Series directory not found"} + # Extract episode data for targeted processing + episodes_data = webhook.episodes or [] + + # For rename events, if no episodes in webhook.episodes, try to extract from episodeFile + if webhook.eventType == "Rename" and not episodes_data and webhook.episodeFile: + episode_file = webhook.episodeFile + # Extract season and episode from episodeFile if available + season_num = episode_file.get("seasonNumber") + episode_num = episode_file.get("episodeNumber") + if season_num and episode_num: + # Create episode data structure that matches what process_webhook_episodes expects + episodes_data = [{ + "seasonNumber": season_num, + "episodeNumber": episode_num, + "id": episode_file.get("id"), + "title": episode_file.get("title") + }] + print(f"INFO: Extracted episode info from episodeFile for rename: S{season_num:02d}E{episode_num:02d}") + # Add to batch queue with TV-prefixed key to avoid movie conflicts tv_batch_key = f"tv:{imdb_id}" webhook_dict = { 'path': str(series_path), 'series_info': series_info, 'event_type': webhook.eventType, - 'episodes': webhook.episodes or [], # Include episode data for targeted processing + 'episodes': episodes_data, # Include enhanced episode data for targeted processing 'processing_mode': config.tv_webhook_processing_mode } batcher.add_webhook(tv_batch_key, webhook_dict, 'tv')