imdb updates

This commit is contained in:
2025-09-09 17:13:14 -04:00
parent 8be7452f0e
commit afe93b4a8a
4 changed files with 90 additions and 9 deletions
+16 -4
View File
@@ -18,8 +18,8 @@ def _log(level: str, msg: str):
class NFOManager:
"""Handles creation and updating of NFO files for movies and TV episodes"""
# Regex patterns
IMDB_TAG_PATTERN = re.compile(r"\[imdb-(tt\d+)\]", re.IGNORECASE)
# Regex patterns - supports both [imdb-tt123] and [tt123] formats
IMDB_TAG_PATTERN = re.compile(r"\[(?:imdb-)?(tt\d+)\]", re.IGNORECASE)
LONG_NFO_PATTERN = re.compile(r".*-S\d{2}E\d{2}-.*\.nfo$", re.IGNORECASE)
SHORT_NFO_PATTERN = re.compile(r"^S(\d{2})E(\d{2})\.nfo$", re.IGNORECASE)
@@ -28,9 +28,21 @@ class NFOManager:
@staticmethod
def parse_imdb_from_path(path: Path) -> Optional[str]:
"""Extract IMDb ID from directory or filename"""
"""Extract IMDb ID from directory or filename, with .nfo fallback"""
# First try path name
match = NFOManager.IMDB_TAG_PATTERN.search(path.name)
return match.group(1).lower() if match else None
if match:
return match.group(1).lower()
# Fallback: scan .nfo files in directory
if path.is_dir():
for nfo_file in path.glob("*.nfo"):
imdb_id = NFOManager.parse_imdb_from_nfo(nfo_file)
if imdb_id:
_log("DEBUG", f"Found IMDb ID {imdb_id} in {nfo_file.name}")
return imdb_id
return None
@staticmethod
def parse_imdb_from_nfo(nfo_path: Path) -> Optional[str]: