mirror of
https://github.com/shadoll/moma.git
synced 2026-08-28 11:33:25 +00:00
- Updated `pyproject.toml` to reflect new package structure. - Created `renamer/__init__.py` to initialize the package. - Implemented `RenamerApp` in `renamer/app.py` for the main application interface. - Added constants for video extensions in `renamer/constants.py`. - Developed `MediaExtractor` class in `renamer/extractor.py` for extracting metadata from media files. - Created various extractor classes in `renamer/extractors/` for handling filename, metadata, and media info extraction. - Added formatting classes in `renamer/formatters/` for displaying media information and proposed filenames. - Implemented utility functions in `renamer/utils.py` for detecting file types and extracting media track information. - Introduced `OpenScreen` in `renamer/screens.py` for user input of directory paths. - Enhanced error handling and user feedback throughout the application.
38 lines
1.6 KiB
Python
38 lines
1.6 KiB
Python
from pathlib import Path
|
|
from ..constants import VIDEO_EXT_DESCRIPTIONS
|
|
from ..utils import detect_file_type
|
|
|
|
|
|
class ExtensionFormatter:
|
|
"""Class for formatting extension information"""
|
|
|
|
@staticmethod
|
|
def check_extension_match(ext_name: str, meta_type: str) -> bool:
|
|
"""Check if file extension matches detected type"""
|
|
if ext_name.upper() == meta_type:
|
|
return True
|
|
elif ext_name == 'mkv' and meta_type == 'Matroska':
|
|
return True
|
|
elif ext_name == 'avi' and meta_type == 'AVI':
|
|
return True
|
|
elif ext_name == 'mov' and meta_type == 'QuickTime':
|
|
return True
|
|
elif ext_name == 'wmv' and meta_type == 'ASF':
|
|
return True
|
|
elif ext_name == 'flv' and meta_type == 'FLV':
|
|
return True
|
|
elif ext_name == 'webm' and meta_type == 'WebM':
|
|
return True
|
|
elif ext_name == 'ogv' and meta_type == 'Ogg':
|
|
return True
|
|
return False
|
|
|
|
@staticmethod
|
|
def format_extension_info(ext_name: str, ext_desc: str, meta_type: str, meta_desc: str, match: bool) -> str:
|
|
"""Format extension information with match status"""
|
|
if match:
|
|
return f"[bold green]Extension:[/bold green] {ext_name} - [grey]{ext_desc}[/grey]"
|
|
else:
|
|
return (f"[bold yellow]Extension:[/bold yellow] {ext_name} - [grey]{ext_desc}[/grey]\n"
|
|
f"[bold red]Meta extension:[/bold red] {meta_type} - [grey]{meta_desc}[/grey]\n"
|
|
"[bold red]Warning: Extensions do not match![/bold red]") |