mirror of
https://github.com/shadoll/moma.git
synced 2026-08-28 19:43:28 +00:00
feat: Bump version to 0.2.9, enhance frame class extraction and add build script
This commit is contained in:
@@ -11,7 +11,6 @@ class FilenameExtractor:
|
||||
def __init__(self, file_path: Path):
|
||||
self.file_path = file_path
|
||||
self.file_name = file_path.name
|
||||
self.file_name = self._normalize_cyrillic(self.file_name)
|
||||
|
||||
def _normalize_cyrillic(self, text: str) -> str:
|
||||
"""Normalize Cyrillic characters to English equivalents for parsing"""
|
||||
@@ -157,10 +156,18 @@ class FilenameExtractor:
|
||||
|
||||
def extract_frame_class(self) -> str | None:
|
||||
"""Extract frame class from filename (480p, 720p, 1080p, 2160p, etc.)"""
|
||||
# First check for specific numeric resolutions
|
||||
match = re.search(r'(\d{3,4})[pi]', self.file_name, re.IGNORECASE)
|
||||
# Normalize Cyrillic characters for resolution parsing
|
||||
normalized_name = self._normalize_cyrillic(self.file_name)
|
||||
|
||||
# First check for specific numeric resolutions with p/i
|
||||
match = re.search(r'(\d{3,4})([pi])', normalized_name, re.IGNORECASE)
|
||||
if match:
|
||||
height = int(match.group(1))
|
||||
scan_type = match.group(2).lower()
|
||||
frame_class = f"{height}{scan_type}"
|
||||
if frame_class in FRAME_CLASSES:
|
||||
return frame_class
|
||||
# Fallback to height-based if not in constants
|
||||
return self._get_frame_class_from_height(height)
|
||||
|
||||
# If no specific resolution found, check for quality indicators
|
||||
|
||||
@@ -59,7 +59,27 @@ class MediaInfoExtractor:
|
||||
return None
|
||||
height = getattr(self.video_tracks[0], 'height', None)
|
||||
if height:
|
||||
return self._get_frame_class_from_height(height)
|
||||
# Check if interlaced
|
||||
interlaced = getattr(self.video_tracks[0], 'interlaced', None)
|
||||
scan_type = 'i' if interlaced == 'Yes' else 'p'
|
||||
|
||||
# First try exact match
|
||||
frame_class = f"{height}{scan_type}"
|
||||
if frame_class in FRAME_CLASSES:
|
||||
return frame_class
|
||||
|
||||
# Find closest height with same scan type
|
||||
closest_height = None
|
||||
min_diff = float('inf')
|
||||
for fc, info in FRAME_CLASSES.items():
|
||||
if fc.endswith(scan_type):
|
||||
diff = abs(height - info['nominal_height'])
|
||||
if diff < min_diff:
|
||||
min_diff = diff
|
||||
closest_height = info['nominal_height']
|
||||
|
||||
if closest_height and min_diff <= 50:
|
||||
return f"{closest_height}{scan_type}"
|
||||
return None
|
||||
|
||||
def extract_resolution(self) -> tuple[int, int] | None:
|
||||
|
||||
Reference in New Issue
Block a user