imdb updates
This commit is contained in:
+16
-4
@@ -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]:
|
||||
|
||||
Reference in New Issue
Block a user