From 5e3d4845b0c5691e1943633cee60a3e6a3729070 Mon Sep 17 00:00:00 2001 From: SBCrumb Date: Thu, 25 Sep 2025 10:38:27 -0400 Subject: [PATCH] fix: Use comprehensive IMDb detection for movie batch validation - Replace simple string search with find_movie_imdb_id() method - Check directory name, filenames, and NFO file content for IMDb ID - Handle both full IMDb IDs (tt26394837) and number formats - Add detailed logging for detected vs expected IMDb matching - Fix validation failures when IMDb ID is in filename/NFO but not directory name Resolves movie webhook processing failures when directory lacks IMDb ID but files contain proper identification. --- nfoguard.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) 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':