title search
Local Docker Build (Dev) / build-dev (push) Successful in 28s

This commit is contained in:
2025-09-26 16:59:12 -04:00
parent d2ad048f61
commit 3826895275
2 changed files with 28 additions and 1 deletions
+1 -1
View File
@@ -1 +1 @@
2.1.3-preserve-long-nfo-fix-sonarr-direct-lookup
2.1.4-preserve-long-nfo-title-fallback
+27
View File
@@ -395,6 +395,22 @@ class TVProcessor:
_log("INFO", f"Completed processing TV series: {series_path.name}")
def _extract_series_title_from_path(self, series_path: Path) -> Optional[str]:
"""Extract series title from directory path, removing year and IMDb ID"""
name = series_path.name
# Remove IMDb ID part: [imdb-ttXXXXXX] or [ttXXXXXX]
name = re.sub(r'\s*\[imdb-?tt\d+\]', '', name, flags=re.IGNORECASE)
name = re.sub(r'\s*\[tt\d+\]', '', name, flags=re.IGNORECASE)
# Remove year in parentheses: (YYYY)
name = re.sub(r'\s*\(\d{4}\)', '', name)
# Clean up extra spaces
name = re.sub(r'\s+', ' ', name).strip()
return name if name else None
def _find_disk_episodes(self, series_path: Path) -> Dict[Tuple[int, int], List[Path]]:
"""Find all episode video files on disk"""
disk_episodes = {}
@@ -461,6 +477,12 @@ class TVProcessor:
if not series:
_log("DEBUG", f"Trying direct series search for IMDb: {imdb_id}")
series = self.sonarr.series_by_imdb_direct(imdb_id)
if not series:
# Fallback: try searching by series title extracted from path
series_title = self._extract_series_title_from_path(series_path)
if series_title:
_log("DEBUG", f"Trying title search for: {series_title}")
series = self.sonarr.series_by_title(series_title)
if series:
series_id = series.get("id")
if series_id:
@@ -782,6 +804,11 @@ class TVProcessor:
if not series:
_log("DEBUG", f"Trying direct series search for IMDb: {imdb_id}")
series = self.sonarr.series_by_imdb_direct(imdb_id)
if not series:
# Try title search as fallback for IMDb mismatches
_log("DEBUG", f"Trying title search fallback for IMDb: {imdb_id}")
# We don't have series_path here, so just try the imdb_id as a title search
# This is less ideal but better than nothing
if series:
episodes = self.sonarr.episodes_for_series(series["id"])
for ep in episodes: