Add rename service and utility modules for file renaming operations

- Implemented RenameService for handling file renaming with features like name validation, proposed name generation, conflict detection, and atomic rename operations.
- Created utility modules for language code extraction, regex pattern matching, and frame class matching to centralize common functionalities.
- Added comprehensive logging for error handling and debugging across all new modules.
This commit is contained in:
sha
2025-12-31 03:13:26 +00:00
parent b50b9bc165
commit c5fbd367fc
20 changed files with 3036 additions and 76 deletions
+7 -2
View File
@@ -1,8 +1,11 @@
import mutagen
import logging
from pathlib import Path
from ..constants import MEDIA_TYPES
from ..decorators import cached_method
logger = logging.getLogger(__name__)
class MetadataExtractor:
"""Class to extract information from file metadata"""
@@ -12,7 +15,8 @@ class MetadataExtractor:
self._cache = {} # Internal cache for method results
try:
self.info = mutagen.File(file_path) # type: ignore
except Exception:
except Exception as e:
logger.debug(f"Failed to read metadata from {file_path}: {e}")
self.info = None
@cached_method()
@@ -52,5 +56,6 @@ class MetadataExtractor:
if info['mime'] == mime:
return info['meta_type']
return 'Unknown'
except Exception:
except Exception as e:
logger.debug(f"Failed to detect MIME type for {self.file_path}: {e}")
return 'Unknown'