mirror of
https://github.com/shadoll/moma.git
synced 2026-08-28 11:33:25 +00:00
- Added `langcodes` dependency for improved language handling. - Replaced `ColorFormatter` with `TextFormatter` for consistent text styling across the application. - Introduced `TrackFormatter` for better track information formatting. - Updated `MediaFormatter` to utilize new formatting methods and improved data handling. - Refactored `MediaExtractor` to enhance data extraction logic and improve readability. - Removed deprecated `ColorFormatter` methods and replaced them with `TextFormatter` equivalents. - Added new methods for extracting and formatting audio and subtitle tracks. - Updated tests to reflect changes in the extraction logic and formatting.
29 lines
1.2 KiB
Python
29 lines
1.2 KiB
Python
from .text_formatter import TextFormatter
|
|
from .date_formatter import DateFormatter
|
|
|
|
|
|
class ProposedNameFormatter:
|
|
"""Class for formatting proposed filenames"""
|
|
|
|
def __init__(self, extractor):
|
|
"""Initialize with media extractor data"""
|
|
|
|
self.__title = extractor.get("title") or "Unknown Title"
|
|
self.__year = DateFormatter.format_year(extractor.get("year"))
|
|
self.__source = f" {extractor.get('source')}" if extractor.get("source") else ""
|
|
self.__frame_class = extractor.get("frame_class") or None
|
|
self.__hdr = f",{extractor.get('hdr')}" if extractor.get("hdr") else ""
|
|
self.__audio_langs = extractor.get("audio_langs") or None
|
|
self.__extension = extractor.get("extension") or "ext"
|
|
|
|
def __str__(self) -> str:
|
|
"""Convert the proposed name to string"""
|
|
return self.rename_line()
|
|
|
|
def rename_line(self) -> str:
|
|
return f"{self.__title} {self.__year}{self.__source} [{self.__frame_class}{self.__hdr},{self.__audio_langs}].{self.__extension}"
|
|
|
|
def rename_line_formatted(self) -> str:
|
|
"""Format the proposed name for display with color"""
|
|
return f">> {TextFormatter.bold_yellow(str(self))} <<"
|