radarr updates
This commit is contained in:
+52
-33
@@ -36,18 +36,26 @@ class RadarrClient:
|
|||||||
|
|
||||||
# Known Radarr event types that indicate actual imports
|
# Known Radarr event types that indicate actual imports
|
||||||
REAL_IMPORT_EVENTS = {
|
REAL_IMPORT_EVENTS = {
|
||||||
# v4+ events
|
# Primary events to check first
|
||||||
|
"moviefileimported",
|
||||||
|
"importevent",
|
||||||
|
# Secondary events
|
||||||
"downloadfolderimported",
|
"downloadfolderimported",
|
||||||
"moviefileimported",
|
|
||||||
"imported",
|
"imported",
|
||||||
"downloadimported",
|
"downloadimported",
|
||||||
"fileimported",
|
"fileimported",
|
||||||
"movieimported",
|
"movieimported",
|
||||||
# v3 events
|
# Legacy events
|
||||||
"downloadedepisode",
|
"downloadedepisode",
|
||||||
"downloadedmovie",
|
"downloadedmovie",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Events that should be checked first
|
||||||
|
PRIMARY_IMPORT_EVENTS = {
|
||||||
|
"moviefileimported",
|
||||||
|
"importevent"
|
||||||
|
}
|
||||||
|
|
||||||
# These are now handled by path_mapper, but keeping for backward compatibility
|
# These are now handled by path_mapper, but keeping for backward compatibility
|
||||||
DOWNLOAD_PATH_INDICATORS = [
|
DOWNLOAD_PATH_INDICATORS = [
|
||||||
'/downloads/', '/download/', '/completed/', '/importing/',
|
'/downloads/', '/download/', '/completed/', '/importing/',
|
||||||
@@ -266,42 +274,53 @@ class RadarrClient:
|
|||||||
except Exception:
|
except Exception:
|
||||||
pass
|
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)
|
is_real, reason, date_iso = self._analyze_event_for_import(event, movie_info)
|
||||||
|
|
||||||
if is_real and date_iso:
|
if is_real and date_iso:
|
||||||
# Extract all possible identifiers
|
|
||||||
source_path = (event.get("data", {}).get("sourcePath", "") or
|
source_path = (event.get("data", {}).get("sourcePath", "") or
|
||||||
event.get("data", {}).get("droppedPath", "") or
|
event.get("data", {}).get("droppedPath", "") or
|
||||||
event.get("sourcePath", "") or "").lower()
|
event.get("sourcePath", "") or
|
||||||
source_title = (event.get("data", {}).get("sourceTitle", "") or
|
event.get("data", {}).get("importedPath", "") or
|
||||||
event.get("sourceTitle", "") or "").lower()
|
event.get("importedPath", "") or "").lower()
|
||||||
|
|
||||||
# Get movie identifiers
|
if source_path:
|
||||||
movie_imdb = (movie_info.get("imdbId", "") or "").lower()
|
# Check for path match
|
||||||
movie_title = (movie_info.get("title", "") or "").lower()
|
movie_imdb = (movie_info.get("imdbId", "") or "").lower()
|
||||||
|
if movie_imdb and (
|
||||||
_log("DEBUG", f"Validating import - Path: {source_path}")
|
f"[imdb-{movie_imdb}]" in source_path or
|
||||||
_log("DEBUG", f"Validating import - Title: {source_title}")
|
f"[{movie_imdb}]" in source_path or
|
||||||
_log("DEBUG", f"Validating against - IMDb: {movie_imdb}, Title: {movie_title}")
|
movie_imdb in source_path
|
||||||
|
):
|
||||||
# More flexible validation
|
_log("INFO", f"✅ FOUND IMPORT: IMDb match in path at {date_iso}")
|
||||||
valid = False
|
earliest_real_import = date_iso
|
||||||
if movie_imdb and (movie_imdb in source_path or movie_imdb in source_title):
|
break
|
||||||
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 valid:
|
# Check for title/year match
|
||||||
_log("INFO", f"✅ FOUND REAL IMPORT: {event_type} at {date_iso} - {reason} (path validated)")
|
movie_title = (movie_info.get("title", "") or "").lower().replace(":", ".").replace(" ", ".")
|
||||||
earliest_real_import = date_iso
|
movie_year = str(movie_info.get("year", ""))
|
||||||
break # Stop processing more pages
|
if movie_title and movie_year and movie_title in source_path and movie_year in source_path:
|
||||||
else:
|
_log("INFO", f"✅ FOUND IMPORT: Title/year match at {date_iso}")
|
||||||
_log("DEBUG", f"⚠️ Skipping import - path validation failed")
|
earliest_real_import = date_iso
|
||||||
# We found a real import - we can stop here since events are chronologically ordered
|
break
|
||||||
break
|
|
||||||
elif event_type in self.REAL_IMPORT_EVENTS:
|
elif event_type in self.REAL_IMPORT_EVENTS:
|
||||||
_log("DEBUG", f"⚠️ Skipped import event: {reason}")
|
_log("DEBUG", f"⚠️ Skipped import event: {reason}")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user