mirror of
https://github.com/shadoll/moma.git
synced 2026-08-28 11:33:25 +00:00
feat: Add extraction and formatting for special edition information in filenames
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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']:
|
||||
|
||||
Reference in New Issue
Block a user