From 946b024fd315641f2a63f8c3810f839fd917d20e Mon Sep 17 00:00:00 2001 From: SBCrumb Date: Mon, 8 Sep 2025 11:20:00 -0400 Subject: [PATCH] more radarr debugs --- VERSION | 2 +- clients/radarr_client.py | 8 +++++++- core/path_mapper.py | 25 ++++++++----------------- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/VERSION b/VERSION index b003284..a45be46 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.2.7 +0.2.8 diff --git a/clients/radarr_client.py b/clients/radarr_client.py index 7899808..b52ce42 100644 --- a/clients/radarr_client.py +++ b/clients/radarr_client.py @@ -97,7 +97,13 @@ class RadarrClient: imdb_id = imdb_id if imdb_id.startswith("tt") else f"tt{imdb_id}" _log("DEBUG", f"Looking up movie by IMDb ID: {imdb_id}") - # Method 1: Get all movies and filter by IMDb (most reliable) + # Method 1: Direct lookup by ID + movie = self._get(f"/api/v3/movie/lookup/imdb/{imdb_id}") + if isinstance(movie, dict) and movie.get("imdbId", "").lower() == imdb_id.lower(): + _log("INFO", f"Found via direct lookup: {movie.get('title')} (ID: {movie.get('id')})") + return movie + + # Method 2: Get all movies and filter by IMDb (fallback) all_movies = self._get("/api/v3/movie") if isinstance(all_movies, list): _log("DEBUG", f"Got {len(all_movies)} total movies, filtering by IMDb ID") diff --git a/core/path_mapper.py b/core/path_mapper.py index 16dbb8f..ce6f5e1 100644 --- a/core/path_mapper.py +++ b/core/path_mapper.py @@ -166,33 +166,24 @@ class PathMapper: path_lower = str(path).lower() return any(indicator in path_lower for indicator in self.download_path_indicators) - def analyze_import_source_path(self, source_path: str, movie_path: str = None) -> Tuple[bool, str]: + def analyze_import_source_path(self, source_path: str) -> Tuple[bool, str]: """ Analyze import source path to determine if it's from downloads. - Args: - source_path: Path to analyze - movie_path: Optional movie path to validate against - Returns: (is_from_downloads, reason) """ if not source_path: return False, "no_source_path" - path_lower = source_path.lower() + path_lower = str(source_path).lower() - # If movie_path is provided, check if source path has matching IMDb ID or movie name - if movie_path: - movie_lower = str(movie_path).lower() - movie_basename = os.path.basename(movie_lower) - source_basename = os.path.basename(path_lower) - - # Extract IMDb ID pattern - imdb_match = re.search(r'tt\d+', movie_basename) - if imdb_match and imdb_match.group(0) in source_basename: - _log("DEBUG", f"Source path matches movie IMDb ID: {imdb_match.group(0)}") - return True, "matched_movie_imdb" + # Extract potential IMDb ID from path + imdb_match = re.search(r'(?:imdb-|tt)(\d{6,8})', path_lower) + if imdb_match: + imdb_id = f"tt{imdb_match.group(1)}" + _log("DEBUG", f"Found IMDb ID in path: {imdb_id}") + return True, f"imdb_in_path({imdb_id})" # Check for download indicators for indicator in self.download_path_indicators: