feat: Improved import detection and reduced debug noise

This commit is contained in:
2025-09-08 13:25:17 -04:00
parent 900da1ba4f
commit 8702c9556d
3 changed files with 27 additions and 15 deletions
+7
View File
@@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
## [Unreleased] ## [Unreleased]
## [0.3.6] - 2025-09-08
### Changed
- Improved import detection filtering
- Reduced debug noise for non-import events
- Enhanced logging clarity for import matches
- Added more context to import event messages
## [0.3.5] - 2025-09-08 ## [0.3.5] - 2025-09-08
### Changed ### Changed
- Improved Radarr import detection to handle more cases - Improved Radarr import detection to handle more cases
+1 -1
View File
@@ -1 +1 @@
0.3.5 0.3.6
+19 -14
View File
@@ -275,6 +275,9 @@ class RadarrClient:
pass pass
# For import/download events, handle specially # For import/download events, handle specially
if event_type not in ["moviefileimported", "downloadFolderImported"]:
continue
imported_path = None imported_path = None
# Try different sources for the path # Try different sources for the path
if event_type == "moviefileimported": if event_type == "moviefileimported":
@@ -287,18 +290,20 @@ class RadarrClient:
event.get("sourcePath", "") or event.get("sourcePath", "") or
event.get("downloadPath", "")).lower() event.get("downloadPath", "")).lower()
if imported_path: if not imported_path:
movie_imdb = (movie_info.get("imdbId", "") or "").lower() continue
movie_title = (movie_info.get("title", "") or "").lower()
movie_year = str(movie_info.get("year", ""))
# First try IMDb ID match movie_imdb = (movie_info.get("imdbId", "") or "").lower()
if movie_imdb and ( movie_title = (movie_info.get("title", "") or "").lower()
f"[imdb-{movie_imdb}]" in imported_path or movie_year = str(movie_info.get("year", ""))
f"[{movie_imdb}]" in imported_path or
movie_imdb in imported_path # First try IMDb ID match
): if movie_imdb and (
_log("DEBUG", f"Found potential import event ({event_type}) matching IMDb {movie_imdb}: {imported_path}") f"[imdb-{movie_imdb}]" in imported_path or
f"[{movie_imdb}]" in imported_path or
movie_imdb in imported_path
):
_log("INFO", f"Found potential IMDb match in {event_type} event: {imported_path}")
date_iso = datetime.fromisoformat(event["date"].replace("Z", "+00:00")).astimezone(timezone.utc).isoformat(timespec="seconds") 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}") _log("INFO", f"✅ FOUND IMPORT: exact IMDb match at {date_iso}")
earliest_real_import = date_iso earliest_real_import = date_iso
@@ -315,11 +320,11 @@ class RadarrClient:
clean_title = clean_title.replace(f".{word}.", ".").replace(f"{word}.", "").replace(f".{word}", "") clean_title = clean_title.replace(f".{word}.", ".").replace(f"{word}.", "").replace(f".{word}", "")
clean_path = clean_path.replace(f".{word}.", ".").replace(f"{word}.", "").replace(f".{word}", "") clean_path = clean_path.replace(f".{word}.", ".").replace(f"{word}.", "").replace(f".{word}", "")
# Look for both title and year # Look for both title and year in the path
if clean_title in clean_path and movie_year in clean_path: if clean_title in clean_path and movie_year in clean_path:
_log("DEBUG", f"Found potential title/year match: {clean_title} ({movie_year}) in {clean_path}")
date_iso = datetime.fromisoformat(event["date"].replace("Z", "+00:00")).astimezone(timezone.utc).isoformat(timespec="seconds") date_iso = datetime.fromisoformat(event["date"].replace("Z", "+00:00")).astimezone(timezone.utc).isoformat(timespec="seconds")
_log("INFO", f"✅ FOUND IMPORT: title/year match at {date_iso}") _log("INFO", f"Found potential title/year match in {event_type} event: {clean_title} ({movie_year})")
_log("INFO", f"✅ FOUND IMPORT at {date_iso}")
earliest_real_import = date_iso earliest_real_import = date_iso
break break