api updates

This commit is contained in:
2025-09-08 10:55:03 -04:00
parent af6e5b5ad1
commit 282717314a
2 changed files with 20 additions and 5 deletions
+1 -1
View File
@@ -1 +1 @@
0.2.3
0.2.4
+18 -3
View File
@@ -125,10 +125,14 @@ class RadarrClient:
_log("ERROR", f"No movie found for IMDb ID: {imdb_id}")
return None
def _analyze_event_for_import(self, event: Dict[str, Any]) -> Tuple[bool, str, Optional[str]]:
def _analyze_event_for_import(self, event: Dict[str, Any], movie_info: Dict[str, Any] = None) -> Tuple[bool, str, Optional[str]]:
"""
Analyze a history event to determine if it's a real import.
Args:
event: The history event to analyze
movie_info: Optional movie information to validate paths against
Returns:
(is_real_import, reason, date_iso)
"""
@@ -179,6 +183,11 @@ class RadarrClient:
"""
_log("INFO", f"Finding earliest import for movie_id {movie_id}")
# Get movie info for path validation
movie_info = self._get("/api/v3/movie", {"movieId": movie_id})
if isinstance(movie_info, list) and movie_info:
movie_info = movie_info[0]
earliest_real_import = None
first_grab = None
page = 1
@@ -217,11 +226,17 @@ class RadarrClient:
pass
# Analyze for real import
is_real, reason, date_iso = self._analyze_event_for_import(event)
is_real, reason, date_iso = self._analyze_event_for_import(event, movie_info)
if is_real and date_iso:
_log("INFO", f"✅ FOUND REAL IMPORT: {event_type} at {date_iso} - {reason}")
source_path = (event.get("data", {}).get("sourcePath") or "").lower()
source_title = (event.get("data", {}).get("sourceTitle") or "").lower()
if movie_info and (movie_info.get("imdbId") or "").lower() in (source_path + source_title):
_log("INFO", f"✅ FOUND REAL IMPORT: {event_type} at {date_iso} - {reason} (path validated)")
earliest_real_import = date_iso
else:
_log("DEBUG", f"⚠️ Skipping import - path validation failed")
# We found a real import - we can stop here since events are chronologically ordered
break
elif event_type in self.REAL_IMPORT_EVENTS: