diff --git a/nfoguard.py b/nfoguard.py index 215e4f1..16ad8ec 100644 --- a/nfoguard.py +++ b/nfoguard.py @@ -1621,11 +1621,23 @@ class WebhookBatcher: # CRITICAL: Validate that the path contains the expected IMDb ID for movies if media_type == 'movie': expected_imdb = key.replace('movie:', '') if key.startswith('movie:') else key - if expected_imdb not in path_str.lower(): + # Use comprehensive IMDb detection (directory, filenames, NFO content) + detected_imdb = self.nfo_manager.find_movie_imdb_id(path) + + # Check if detected IMDb matches expected (handle both full IMDb IDs and just numbers) + imdb_match = False + if detected_imdb: + if detected_imdb == expected_imdb: + imdb_match = True + elif detected_imdb.replace('tt', '') == expected_imdb.replace('tt', ''): + imdb_match = True + + if not imdb_match: _log("ERROR", f"BATCH VALIDATION FAILED: Expected IMDb {expected_imdb} not found in path {path_str}") + _log("ERROR", f"Detected IMDb: {detected_imdb}, Expected: {expected_imdb}") _log("ERROR", f"This prevents processing wrong movies due to batch corruption") return - _log("DEBUG", f"Batch validation passed: IMDb {expected_imdb} found in path") + _log("DEBUG", f"Batch validation passed: Expected IMDb {expected_imdb} matches detected IMDb {detected_imdb}") # Process based on media type if media_type == 'tv':