Refactor extractors and formatters for improved structure and functionality

- Converted static methods to instance methods in FileInfoExtractor and FilenameExtractor for better encapsulation.
- Enhanced MediaInfoExtractor to initialize with file path and extract media information upon instantiation.
- Updated MetadataExtractor to handle metadata extraction with improved error handling and added methods for meta type detection.
- Introduced ColorFormatter for consistent text formatting across the application.
- Refactored MediaFormatter to utilize the new extractor structure and improve output formatting.
- Removed redundant utility functions and replaced them with direct calls in extractors.
- Added ProposedNameFormatter for better handling of proposed filename formatting.
- Updated extension handling to use MEDIA_TYPES for descriptions instead of VIDEO_EXT_DESCRIPTIONS.
This commit is contained in:
sha
2025-12-25 23:35:59 +00:00
parent 37efdf60d3
commit d2ec235458
14 changed files with 664 additions and 500 deletions
+19 -12
View File
@@ -4,22 +4,29 @@ from pathlib import Path
class FileInfoExtractor:
"""Class to extract file information"""
@staticmethod
def extract_size(file_path: Path) -> int:
def __init__(self, file_path: Path):
self.file_path = file_path
self._size = file_path.stat().st_size
self._modification_time = file_path.stat().st_mtime
self._file_name = file_path.name
self._file_path = str(file_path)
def extract_size(self) -> int:
"""Extract file size in bytes"""
return file_path.stat().st_size
return self._size
@staticmethod
def extract_modification_time(file_path: Path) -> float:
def extract_modification_time(self) -> float:
"""Extract file modification time"""
return file_path.stat().st_mtime
return self._modification_time
@staticmethod
def extract_file_name(file_path: Path) -> str:
def extract_file_name(self) -> str:
"""Extract file name"""
return file_path.name
return self._file_name
@staticmethod
def extract_file_path(file_path: Path) -> str:
def extract_file_path(self) -> str:
"""Extract full file path as string"""
return str(file_path)
return self._file_path
def extract_extension(self) -> str:
"""Extract file extension without the dot"""
return self.file_path.suffix.lower().lstrip('.')