mirror of
https://github.com/shadoll/moma.git
synced 2026-08-28 03:27:34 +00:00
feat: Bump version to 0.2.5, enhance logging, normalize Cyrillic characters, and improve database info formatting
This commit is contained in:
@@ -1,4 +1,13 @@
|
||||
from pathlib import Path
|
||||
import logging
|
||||
import os
|
||||
|
||||
# Set up logging conditionally
|
||||
if os.getenv('FORMATTER_LOG', '0') == '1':
|
||||
logging.basicConfig(filename='formatter.log', level=logging.INFO,
|
||||
format='%(asctime)s - %(levelname)s - %(message)s')
|
||||
else:
|
||||
logging.basicConfig(level=logging.CRITICAL) # Disable logging
|
||||
|
||||
|
||||
class FileInfoExtractor:
|
||||
@@ -10,6 +19,7 @@ class FileInfoExtractor:
|
||||
self._modification_time = file_path.stat().st_mtime
|
||||
self._file_name = file_path.name
|
||||
self._file_path = str(file_path)
|
||||
logging.info(f"FileInfoExtractor: file_name={self._file_name!r}, file_path={self._file_path!r}")
|
||||
|
||||
def extract_size(self) -> int:
|
||||
"""Extract file size in bytes"""
|
||||
|
||||
@@ -11,6 +11,18 @@ 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"""
|
||||
replacements = {
|
||||
'р': 'p',
|
||||
'і': 'i',
|
||||
# Add more as needed
|
||||
}
|
||||
for cyr, eng in replacements.items():
|
||||
text = text.replace(cyr, eng)
|
||||
return text
|
||||
|
||||
def _get_frame_class_from_height(self, height: int) -> str | None:
|
||||
"""Get frame class from video height using FRAME_CLASSES constant"""
|
||||
|
||||
@@ -73,10 +73,10 @@ class MediaInfoExtractor:
|
||||
return 'HDR'
|
||||
return None
|
||||
|
||||
def extract_audio_langs(self) -> str:
|
||||
def extract_audio_langs(self) -> str | None:
|
||||
"""Extract audio languages from media info"""
|
||||
if not self.audio_tracks:
|
||||
return ''
|
||||
return None
|
||||
langs = []
|
||||
for a in self.audio_tracks:
|
||||
lang_code = getattr(a, 'language', 'und').lower()
|
||||
|
||||
Reference in New Issue
Block a user