feat: Add extraction and formatting for special edition information in filenames

This commit is contained in:
sha
2025-12-26 20:56:22 +00:00
parent b21308c7b8
commit 691d1e7b2d
7 changed files with 101 additions and 8 deletions
+3
View File
@@ -22,6 +22,9 @@ class DefaultExtractor:
def extract_movie_db(self):
return None
def extract_special_info(self):
return []
def extract_audio_langs(self):
return None
+25 -1
View File
@@ -1,7 +1,7 @@
import re
from pathlib import Path
from collections import Counter
from ..constants import SOURCE_DICT, FRAME_CLASSES, MOVIE_DB_DICT
from ..constants import SOURCE_DICT, FRAME_CLASSES, MOVIE_DB_DICT, SPECIAL_EDITIONS
import langcodes
@@ -192,6 +192,30 @@ class FilenameExtractor:
return None
def extract_special_info(self) -> list[str]:
"""Extract special edition information from filename"""
# Look for special edition indicators in brackets or as standalone text
special_info = []
for edition in SPECIAL_EDITIONS:
# Check in brackets: [Theatrical Cut], [Director's Cut], etc.
bracket_pattern = r'\[([^\]]+)\]'
brackets = re.findall(bracket_pattern, self.file_name)
for bracket in brackets:
# Check if bracket contains comma-separated items
items = [item.strip() for item in bracket.split(',')]
for item in items:
if edition.lower() == item.lower().strip():
if edition not in special_info:
special_info.append(edition)
# Check as standalone text (case-insensitive)
if re.search(r'\b' + re.escape(edition) + r'\b', self.file_name, re.IGNORECASE):
if edition not in special_info:
special_info.append(edition)
return special_info
def extract_audio_langs(self) -> str:
"""Extract audio languages from filename"""
# Look for language patterns in brackets and outside brackets
+1 -1
View File
@@ -21,7 +21,7 @@ class MediaInfoExtractor:
self.audio_tracks = []
self.sub_tracks = []
def _get_frame_class_from_height(self, height: int) -> str:
def _get_frame_class_from_height(self, height: int) -> str | None:
"""Get frame class from video height using FRAME_CLASSES constant"""
for frame_class, info in FRAME_CLASSES.items():
if height == info['nominal_height']: