radarr updates

This commit is contained in:
2025-09-08 11:49:18 -04:00
parent e89eb73bb4
commit e4da166300
2 changed files with 53 additions and 34 deletions
+1 -1
View File
@@ -1 +1 @@
0.3.1
0.3.2
+52 -33
View File
@@ -36,18 +36,26 @@ class RadarrClient:
# Known Radarr event types that indicate actual imports
REAL_IMPORT_EVENTS = {
# v4+ events
# Primary events to check first
"moviefileimported",
"importevent",
# Secondary events
"downloadfolderimported",
"moviefileimported",
"imported",
"downloadimported",
"fileimported",
"movieimported",
# v3 events
# Legacy events
"downloadedepisode",
"downloadedmovie",
}
# Events that should be checked first
PRIMARY_IMPORT_EVENTS = {
"moviefileimported",
"importevent"
}
# These are now handled by path_mapper, but keeping for backward compatibility
DOWNLOAD_PATH_INDICATORS = [
'/downloads/', '/download/', '/completed/', '/importing/',
@@ -266,42 +274,53 @@ class RadarrClient:
except Exception:
pass
# Analyze for real import
# For moviefileimported events, handle specially
if event_type == "moviefileimported":
imported_path = (event.get("data", {}).get("importedPath", "") or
event.get("data", {}).get("path", "") or
event.get("importedPath", "")).lower()
if imported_path:
_log("DEBUG", f"Found moviefileimported event with path: {imported_path}")
# Check for IMDb ID match
movie_imdb = (movie_info.get("imdbId", "") or "").lower()
if movie_imdb and (
f"[imdb-{movie_imdb}]" in imported_path or
f"[{movie_imdb}]" in imported_path
):
date_iso = datetime.fromisoformat(event["date"].replace("Z", "+00:00")).astimezone(timezone.utc).isoformat(timespec="seconds")
_log("INFO", f"✅ FOUND IMPORT: exact IMDb match at {date_iso}")
earliest_real_import = date_iso
break # Stop processing more pages
# Fallback to normal import analysis
is_real, reason, date_iso = self._analyze_event_for_import(event, movie_info)
if is_real and date_iso:
# Extract all possible identifiers
source_path = (event.get("data", {}).get("sourcePath", "") or
event.get("data", {}).get("droppedPath", "") or
event.get("sourcePath", "") or "").lower()
source_title = (event.get("data", {}).get("sourceTitle", "") or
event.get("sourceTitle", "") or "").lower()
event.get("sourcePath", "") or
event.get("data", {}).get("importedPath", "") or
event.get("importedPath", "") or "").lower()
# Get movie identifiers
movie_imdb = (movie_info.get("imdbId", "") or "").lower()
movie_title = (movie_info.get("title", "") or "").lower()
_log("DEBUG", f"Validating import - Path: {source_path}")
_log("DEBUG", f"Validating import - Title: {source_title}")
_log("DEBUG", f"Validating against - IMDb: {movie_imdb}, Title: {movie_title}")
# More flexible validation
valid = False
if movie_imdb and (movie_imdb in source_path or movie_imdb in source_title):
valid = True
_log("DEBUG", "✅ Validated by IMDb ID")
elif movie_title and (movie_title in source_path or movie_title in source_title):
valid = True
_log("DEBUG", "✅ Validated by title")
if source_path:
# Check for path match
movie_imdb = (movie_info.get("imdbId", "") or "").lower()
if movie_imdb and (
f"[imdb-{movie_imdb}]" in source_path or
f"[{movie_imdb}]" in source_path or
movie_imdb in source_path
):
_log("INFO", f"✅ FOUND IMPORT: IMDb match in path at {date_iso}")
earliest_real_import = date_iso
break
if valid:
_log("INFO", f"✅ FOUND REAL IMPORT: {event_type} at {date_iso} - {reason} (path validated)")
earliest_real_import = date_iso
break # Stop processing more pages
else:
_log("DEBUG", f"⚠️ Skipping import - path validation failed")
# We found a real import - we can stop here since events are chronologically ordered
break
# Check for title/year match
movie_title = (movie_info.get("title", "") or "").lower().replace(":", ".").replace(" ", ".")
movie_year = str(movie_info.get("year", ""))
if movie_title and movie_year and movie_title in source_path and movie_year in source_path:
_log("INFO", f"✅ FOUND IMPORT: Title/year match at {date_iso}")
earliest_real_import = date_iso
break
elif event_type in self.REAL_IMPORT_EVENTS:
_log("DEBUG", f"⚠️ Skipped import event: {reason}")