From 1ea7edeefa7d07a9ebc0ff53fb556f872cf5e4e5 Mon Sep 17 00:00:00 2001 From: SBCrumb Date: Mon, 8 Sep 2025 11:33:39 -0400 Subject: [PATCH] more api radarr changes --- VERSION | 2 +- clients/radarr_client.py | 62 +++++++++++++++++++++++++++++----------- 2 files changed, 47 insertions(+), 17 deletions(-) diff --git a/VERSION b/VERSION index a45be46..0d91a54 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.2.8 +0.3.0 diff --git a/clients/radarr_client.py b/clients/radarr_client.py index b52ce42..59b1053 100644 --- a/clients/radarr_client.py +++ b/clients/radarr_client.py @@ -161,26 +161,56 @@ class RadarrClient: if event_type not in self.REAL_IMPORT_EVENTS: return False, f"event_type_not_import({event_type})", date_iso - # Extract source path information - source_path = ( - event_data.get('droppedPath', '') or - event_data.get('sourcePath', '') or - event_data.get('path', '') or - event_data.get('sourceTitle', '') or - event.get('sourcePath', '') or - event.get('sourceTitle', '') - ).lower() + # Get all possible source paths/titles + source_items = [] - if not source_path: - return False, "no_source_path", date_iso + # Get both sourcePath and importedPath if available + if event_data: + for key in ['sourcePath', 'droppedPath', 'path', 'sourceTitle', 'importedPath']: + if event_data.get(key): + source_items.append(event_data[key]) + + # Also check event root for these fields + for key in ['sourcePath', 'sourceTitle', 'importedPath']: + if event.get(key): + source_items.append(event[key]) - # Use path mapper for more sophisticated path analysis - is_from_downloads, path_reason = path_mapper.analyze_import_source_path(source_path) + # Clean up and make unique + source_items = [str(s).lower().strip() for s in source_items if s] + source_items = list(set(source_items)) # Remove duplicates - if not is_from_downloads: - return False, f"not_from_downloads({path_reason})", date_iso + if not source_items: + return False, "no_source_paths", date_iso - return True, f"real_import_from_downloads({path_reason})", date_iso + # If we have movie info, look for title/year match + if movie_info: + movie_title = movie_info.get('title', '').lower().replace(':', '.').replace(' ', '.') + movie_year = str(movie_info.get('year', '')) + + for source in source_items: + # Clean up source text for comparison + source_clean = source.replace(' ', '.').replace('_', '.').replace('-', '.') + + # Check if both title and year are in the source + if movie_title and movie_year: + if movie_title in source_clean and movie_year in source_clean: + _log("DEBUG", f"✅ Match found - Title: {movie_title}, Year: {movie_year}") + return True, "matched_title_and_year", date_iso + + # Also check for downloads path as secondary validation + if path_mapper.is_download_path(source): + _log("DEBUG", f"Source is from downloads: {source}") + return True, "from_downloads_path", date_iso + + _log("DEBUG", f"⚠️ No match found in sources: {source_items}") + return False, "no_title_year_match", date_iso + + # Fallback to basic path validation if no movie info + for source in source_items: + if path_mapper.is_download_path(source): + return True, "basic_download_path_match", date_iso + + return False, "no_download_path_match", date_iso def earliest_import_event_optimized(self, movie_id: int) -> Optional[str]: """