another radarr fix
This commit is contained in:
+26
-8
@@ -348,28 +348,39 @@ class RadarrClient:
|
|||||||
imdb_id = imdb_id if imdb_id.startswith("tt") else f"tt{imdb_id}"
|
imdb_id = imdb_id if imdb_id.startswith("tt") else f"tt{imdb_id}"
|
||||||
_log("DEBUG", f"Radarr API: Looking up movie by IMDb ID: {imdb_id}")
|
_log("DEBUG", f"Radarr API: Looking up movie by IMDb ID: {imdb_id}")
|
||||||
|
|
||||||
# Try direct movie search with IMDb filter (even if unreliable)
|
# Try getting ALL movies first, then filter by IMDb ID (more reliable)
|
||||||
|
all_movies = self._get("/api/v3/movie")
|
||||||
|
if isinstance(all_movies, list):
|
||||||
|
_log("DEBUG", f"Radarr API: Got {len(all_movies)} total movies, filtering by IMDb ID")
|
||||||
|
for movie in all_movies:
|
||||||
|
movie_imdb = movie.get("imdbId", "").lower()
|
||||||
|
if movie_imdb == imdb_id.lower():
|
||||||
|
_log("INFO", f"Radarr API: Found exact match: {movie.get('title')} (ID: {movie.get('id')}, IMDb: {movie_imdb})")
|
||||||
|
return movie
|
||||||
|
|
||||||
|
_log("WARNING", f"Radarr API: Movie not found in library for IMDb ID: {imdb_id}")
|
||||||
|
|
||||||
|
# Fallback: Try direct movie search with IMDb filter
|
||||||
res = self._get("/api/v3/movie", {"imdbId": imdb_id})
|
res = self._get("/api/v3/movie", {"imdbId": imdb_id})
|
||||||
if isinstance(res, list) and len(res) > 0:
|
if isinstance(res, list) and len(res) > 0:
|
||||||
# CRITICAL: Validate that returned movie actually matches requested IMDb ID
|
# CRITICAL: Validate that returned movie actually matches requested IMDb ID
|
||||||
for movie in res:
|
for movie in res:
|
||||||
movie_imdb = movie.get("imdbId", "").lower()
|
movie_imdb = movie.get("imdbId", "").lower()
|
||||||
if movie_imdb == imdb_id.lower():
|
if movie_imdb == imdb_id.lower():
|
||||||
_log("DEBUG", f"Radarr API: Found exact match: {movie.get('title')} (ID: {movie.get('id')})")
|
_log("DEBUG", f"Radarr API: Found via search: {movie.get('title')} (ID: {movie.get('id')})")
|
||||||
return movie
|
return movie
|
||||||
|
|
||||||
# Log the mismatch for debugging
|
# Log the mismatch for debugging
|
||||||
returned_ids = [m.get("imdbId", "None") for m in res[:3]] # Show first 3
|
returned_ids = [m.get("imdbId", "None") for m in res[:3]] # Show first 3
|
||||||
_log("ERROR", f"Radarr API returned WRONG movies for {imdb_id}! Got: {returned_ids}")
|
_log("ERROR", f"Radarr API returned WRONG movies for {imdb_id}! Got: {returned_ids}")
|
||||||
_log("DEBUG", f"Will reject mismatched results and try lookup endpoint")
|
|
||||||
|
|
||||||
# Fallback: Try lookup endpoint which might be more reliable
|
# Final fallback: Try lookup endpoint
|
||||||
res = self._get("/api/v3/movie/lookup/imdb", {"imdbId": imdb_id})
|
res = self._get("/api/v3/movie/lookup/imdb", {"imdbId": imdb_id})
|
||||||
if isinstance(res, dict) and res.get("imdbId", "").lower() == imdb_id.lower():
|
if isinstance(res, dict) and res.get("imdbId", "").lower() == imdb_id.lower():
|
||||||
_log("DEBUG", f"Radarr API: Found movie via lookup: {res.get('title')} (ID: {res.get('id')})")
|
_log("DEBUG", f"Radarr API: Found movie via lookup: {res.get('title')} (ID: {res.get('id')})")
|
||||||
return res
|
return res
|
||||||
|
|
||||||
_log("WARNING", f"Radarr API: No valid movie found for IMDb ID: {imdb_id}")
|
_log("ERROR", f"Radarr API: No valid movie found for IMDb ID: {imdb_id}")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def movie_files(self, movie_id: int) -> List[Dict[str, Any]]:
|
def movie_files(self, movie_id: int) -> List[Dict[str, Any]]:
|
||||||
@@ -460,7 +471,13 @@ class RadarrClient:
|
|||||||
if ev in import_events:
|
if ev in import_events:
|
||||||
# Check if this is a real import (from downloads) vs existing file rename
|
# Check if this is a real import (from downloads) vs existing file rename
|
||||||
event_data = it.get('data', {})
|
event_data = it.get('data', {})
|
||||||
source_path = event_data.get('sourcePath', '') or event_data.get('path', '') or event_data.get('sourceTitle', '')
|
# Prioritize droppedPath which contains the actual source directory
|
||||||
|
source_path = (
|
||||||
|
event_data.get('droppedPath', '') or
|
||||||
|
event_data.get('sourcePath', '') or
|
||||||
|
event_data.get('path', '') or
|
||||||
|
event_data.get('sourceTitle', '')
|
||||||
|
)
|
||||||
|
|
||||||
_log("INFO", f"Analyzing import event '{ev}' with source: '{source_path}'")
|
_log("INFO", f"Analyzing import event '{ev}' with source: '{source_path}'")
|
||||||
|
|
||||||
@@ -1764,8 +1781,9 @@ async def debug_movie_import_date(imdb_id: str):
|
|||||||
date_str = record.get("date", "")
|
date_str = record.get("date", "")
|
||||||
event_data = record.get("data", {})
|
event_data = record.get("data", {})
|
||||||
|
|
||||||
# Try multiple ways to get source path info
|
# Try multiple ways to get source path info - prioritize droppedPath
|
||||||
source_path = (
|
source_path = (
|
||||||
|
event_data.get('droppedPath', '') or # This contains the real download path!
|
||||||
event_data.get('sourcePath', '') or
|
event_data.get('sourcePath', '') or
|
||||||
event_data.get('path', '') or
|
event_data.get('path', '') or
|
||||||
event_data.get('sourceTitle', '') or
|
event_data.get('sourceTitle', '') or
|
||||||
@@ -1777,7 +1795,7 @@ async def debug_movie_import_date(imdb_id: str):
|
|||||||
is_import_type = any(word in event_type.lower() for word in ['import', 'download'])
|
is_import_type = any(word in event_type.lower() for word in ['import', 'download'])
|
||||||
is_from_downloads = any(indicator in source_path.lower() for indicator in [
|
is_from_downloads = any(indicator in source_path.lower() for indicator in [
|
||||||
'/downloads/', '/download/', '/completed/', '/nzbs/', '/torrents/',
|
'/downloads/', '/download/', '/completed/', '/nzbs/', '/torrents/',
|
||||||
'nzbget', 'sabnzbd', 'radarr', 'completed'
|
'nzbget', 'sabnzbd', 'radarr', 'completed/'
|
||||||
])
|
])
|
||||||
|
|
||||||
# Check for July 7 events specifically
|
# Check for July 7 events specifically
|
||||||
|
|||||||
Reference in New Issue
Block a user