This commit is contained in:
@@ -261,6 +261,36 @@ class TVProcessor:
|
|||||||
"""Get episode information from Sonarr including import history - optimized to only fetch needed episodes"""
|
"""Get episode information from Sonarr including import history - optimized to only fetch needed episodes"""
|
||||||
try:
|
try:
|
||||||
series_data = self.sonarr.series_by_imdb(imdb_id)
|
series_data = self.sonarr.series_by_imdb(imdb_id)
|
||||||
|
if not series_data:
|
||||||
|
# Try fuzzy matching if exact IMDb lookup fails
|
||||||
|
_log("DEBUG", f"Exact IMDb lookup failed for {imdb_id}, trying fuzzy matching")
|
||||||
|
|
||||||
|
# Get all series and try fuzzy matching
|
||||||
|
all_series = self.sonarr.get("/series")
|
||||||
|
if all_series:
|
||||||
|
_log("DEBUG", f"Found {len(all_series)} total series in Sonarr")
|
||||||
|
|
||||||
|
for series in all_series:
|
||||||
|
series_imdb = series.get('imdbId', '')
|
||||||
|
if series_imdb and series_imdb.startswith('tt'):
|
||||||
|
# Try fuzzy matching for IMDb numbers
|
||||||
|
try:
|
||||||
|
target_imdb_num = imdb_id.replace('tt', '').lower()
|
||||||
|
series_imdb_num = series_imdb.replace('tt', '').lower()
|
||||||
|
|
||||||
|
target_num = int(target_imdb_num)
|
||||||
|
series_num = int(series_imdb_num)
|
||||||
|
diff = abs(target_num - series_num)
|
||||||
|
|
||||||
|
if diff <= 10: # Allow small IMDb ID differences
|
||||||
|
_log("INFO", f"✅ Found fuzzy IMDb match: {series_imdb} vs {imdb_id} (diff: {diff})")
|
||||||
|
_log("DEBUG", f"Series data found: True")
|
||||||
|
_log("DEBUG", f"Found series '{series.get('title', 'Unknown')}' with ID {series.get('id')}")
|
||||||
|
series_data = series
|
||||||
|
break
|
||||||
|
except (ValueError, TypeError):
|
||||||
|
continue
|
||||||
|
|
||||||
if not series_data:
|
if not series_data:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user