Add ProposedFilenameView and MediaPanelView with comprehensive tests

- Implemented ProposedFilenameView to generate standardized filenames using a decorator pattern.
- Created MediaPanelView to assemble media data panels for display, aggregating multiple formatters.
- Added tests for ProposedFilenameView covering various formatting scenarios, including basic, minimal, and special cases.
- Introduced a views package to organize and expose the new views.
- Ensured proper formatting and display of media information, including file info, TMDB data, and track information.
This commit is contained in:
sha
2026-01-02 12:29:04 +00:00
parent e64aaf320b
commit 981000793f
11 changed files with 70 additions and 48 deletions
+3 -4
View File
@@ -16,9 +16,8 @@ from threading import Lock
from renamer.cache import Cache
from renamer.settings import Settings
from renamer.extractors.extractor import MediaExtractor
from renamer.formatters.media_formatter import MediaFormatter
from renamer.views import MediaPanelView, ProposedFilenameView
from renamer.formatters.catalog_formatter import CatalogFormatter
from renamer.formatters.proposed_name_formatter import ProposedNameFormatter
from renamer.formatters.text_formatter import TextFormatter
@@ -171,14 +170,14 @@ class MetadataService:
# Format based on mode
if mode == "technical":
formatter = MediaFormatter(extractor)
formatter = MediaPanelView(extractor)
formatted_info = formatter.file_info_panel()
else: # catalog
formatter = CatalogFormatter(extractor)
formatted_info = formatter.format_catalog_info()
# Generate proposed name
proposed_formatter = ProposedNameFormatter(extractor)
proposed_formatter = ProposedFilenameView(extractor)
proposed_name = proposed_formatter.rename_line_formatted(file_path)
return {
+2 -2
View File
@@ -14,7 +14,7 @@ from pathlib import Path
from typing import Optional, Callable
from renamer.extractors.extractor import MediaExtractor
from renamer.formatters.proposed_name_formatter import ProposedNameFormatter
from renamer.views import ProposedFilenameView
logger = logging.getLogger(__name__)
@@ -80,7 +80,7 @@ class RenameService:
if extractor is None:
extractor = MediaExtractor(file_path)
formatter = ProposedNameFormatter(extractor)
formatter = ProposedFilenameView(extractor)
# Get the formatted rename line
rename_line = formatter.rename_line_formatted(file_path)