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
+71 -60
View File
@@ -1,72 +1,83 @@
VIDEO_EXTENSIONS = {'.mkv', '.avi', '.mov', '.mp4', '.wmv', '.flv', '.webm', '.m4v', '.3gp', '.ogv'}
VIDEO_EXT_DESCRIPTIONS = {
'mkv': 'Matroska multimedia container',
'avi': 'Audio Video Interleave',
'mov': 'QuickTime movie',
'mp4': 'MPEG-4 video container',
'wmv': 'Windows Media Video',
'flv': 'Flash Video',
'webm': 'WebM multimedia',
'm4v': 'MPEG-4 video',
'3gp': '3GPP multimedia',
'ogv': 'Ogg Video',
}
META_DESCRIPTIONS = {
'MP4': 'MPEG-4 video container',
'Matroska': 'Matroska multimedia container',
'AVI': 'Audio Video Interleave',
'QuickTime': 'QuickTime movie',
'ASF': 'Windows Media',
'FLV': 'Flash Video',
'WebM': 'WebM multimedia',
'Ogg': 'Ogg multimedia',
MEDIA_TYPES = {
"mkv": {
"description": "Matroska multimedia container",
"meta_type": "Matroska",
"mime": "video/x-matroska",
},
"avi": {
"description": "Audio Video Interleave",
"meta_type": "AVI",
"mime": "video/x-msvideo",
},
"mov": {
"description": "QuickTime movie",
"meta_type": "QuickTime",
"mime": "video/quicktime",
},
"mp4": {
"description": "MPEG-4 video container",
"meta_type": "MP4",
"mime": "video/mp4",
},
"wmv": {
"description": "Windows Media Video",
"meta_type": "ASF",
"mime": "video/x-ms-wmv",
},
"flv": {"description": "Flash Video", "meta_type": "FLV", "mime": "video/x-flv"},
"webm": {
"description": "WebM multimedia",
"meta_type": "WebM",
"mime": "video/webm",
},
"m4v": {"description": "MPEG-4 video", "meta_type": "MP4", "mime": "video/mp4"},
"3gp": {"description": "3GPP multimedia", "meta_type": "MP4", "mime": "video/3gpp"},
"ogv": {"description": "Ogg Video", "meta_type": "Ogg", "mime": "video/ogg"},
}
SOURCE_DICT = {
'WEB-DL': ['WEB-DL', 'WEBRip', 'WEB-Rip', 'WEB'],
'BDRip': ['BDRip', 'BD-Rip', 'BDRIP'],
'BDRemux': ['BDRemux', 'BD-Remux', 'BDREMUX'],
'DVDRip': ['DVDRip', 'DVD-Rip', 'DVDRIP'],
'HDTV': ['HDTV'],
'BluRay': ['BluRay', 'BLURAY', 'Blu-ray'],
"WEB-DL": ["WEB-DL", "WEBRip", "WEB-Rip", "WEB"],
"BDRip": ["BDRip", "BD-Rip", "BDRIP"],
"BDRemux": ["BDRemux", "BD-Remux", "BDREMUX"],
"DVDRip": ["DVDRip", "DVD-Rip", "DVDRIP"],
"HDTV": ["HDTV"],
"BluRay": ["BluRay", "BLURAY", "Blu-ray"],
}
FRAME_CLASSES = {
'480p': {
'nominal_height': 480,
'typical_widths': [640, 704, 720],
'description': 'Standard Definition (SD) - DVD quality'
"480p": {
"nominal_height": 480,
"typical_widths": [640, 704, 720],
"description": "Standard Definition (SD) - DVD quality",
},
'576p': {
'nominal_height': 576,
'typical_widths': [720, 768],
'description': 'PAL Standard Definition (SD) - European DVD quality'
"576p": {
"nominal_height": 576,
"typical_widths": [720, 768],
"description": "PAL Standard Definition (SD) - European DVD quality",
},
'720p': {
'nominal_height': 720,
'typical_widths': [1280],
'description': 'High Definition (HD) - 720p HD'
"720p": {
"nominal_height": 720,
"typical_widths": [1280],
"description": "High Definition (HD) - 720p HD",
},
'1080p': {
'nominal_height': 1080,
'typical_widths': [1920],
'description': 'Full High Definition (FHD) - 1080p HD'
"1080p": {
"nominal_height": 1080,
"typical_widths": [1920],
"description": "Full High Definition (FHD) - 1080p HD",
},
'1440p': {
'nominal_height': 1440,
'typical_widths': [2560],
'description': 'Quad High Definition (QHD) - 1440p 2K'
"1440p": {
"nominal_height": 1440,
"typical_widths": [2560],
"description": "Quad High Definition (QHD) - 1440p 2K",
},
'2160p': {
'nominal_height': 2160,
'typical_widths': [3840],
'description': 'Ultra High Definition (UHD) - 2160p 4K'
"2160p": {
"nominal_height": 2160,
"typical_widths": [3840],
"description": "Ultra High Definition (UHD) - 2160p 4K",
},
'4320p': {
'nominal_height': 4320,
'typical_widths': [7680],
'description': 'Ultra High Definition (UHD) - 4320p 8K'
}
}
"4320p": {
"nominal_height": 4320,
"typical_widths": [7680],
"description": "Ultra High Definition (UHD) - 4320p 8K",
},
}