feat: Add comprehensive IMDb detection for TV shows
Local Docker Build (Dev) / build-dev (pull_request) Successful in 4s

- Add find_series_imdb_id method to check directory, filenames, and tvshow.nfo
- Add TV show batch validation in webhook batcher (like movies)
- Ensures TV webhooks process correct series by validating IMDb match
- Prevents mismatched processing like Girls (2012) -> Gachiakuta (2025)
- Comprehensive detection checks: folder name, file names, NFO content
This commit is contained in:
2025-10-12 10:46:43 -04:00
parent 41bccb82b1
commit 348f83d547
2 changed files with 57 additions and 1 deletions
+26 -1
View File
@@ -107,8 +107,33 @@ class WebhookBatcher:
return
_log("DEBUG", f"Batch validation passed: IMDb {expected_imdb} found in path (fallback mode)")
# Process based on media type
# CRITICAL: Validate that the path contains the expected IMDb ID for TV shows
if media_type == 'tv':
expected_imdb = key.replace('tv:', '') if key.startswith('tv:') else key
# Use comprehensive IMDb detection (directory, filenames, tvshow.nfo files)
if self.nfo_manager:
detected_imdb = self.nfo_manager.find_series_imdb_id(path_obj)
imdb_match = False
if detected_imdb:
# Compare with and without 'tt' prefix for flexibility
if detected_imdb == expected_imdb or 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 via comprehensive detection in TV path {path_str}")
_log("ERROR", f"Detected TV IMDb: {detected_imdb}, Expected: {expected_imdb}")
_log("ERROR", f"This prevents processing wrong TV series due to batch corruption")
return
_log("DEBUG", f"TV batch validation passed: IMDb {expected_imdb} matches detected {detected_imdb}")
else:
# Fallback to simple string search if nfo_manager not available
if expected_imdb not in path_str.lower():
_log("ERROR", f"BATCH VALIDATION FAILED: Expected IMDb {expected_imdb} not found in TV path {path_str} (fallback mode)")
_log("ERROR", f"This prevents processing wrong TV series due to batch corruption")
return
_log("DEBUG", f"TV batch validation passed: IMDb {expected_imdb} found in path (fallback mode)")
if not self.tv_processor:
_log("ERROR", "TV processor not available")
return