mirror of
https://github.com/shadoll/moma.git
synced 2026-08-28 19:43:28 +00:00
- Introduced `DurationDecorators` for full and short duration formatting. - Added `ExtensionDecorators` for formatting extension information. - Created `ResolutionDecorators` for formatting resolution dimensions. - Implemented `SizeDecorators` for full and short size formatting. - Enhanced `TextDecorators` with additional formatting options including blue and grey text, URL formatting, and escaping rich markup. - Developed `TrackDecorators` for formatting video, audio, and subtitle track data. - Refactored `MediaPanelView` to utilize a new `MediaPanelProperties` class for cleaner property management and formatting. - Updated `media_panel_properties.py` to include formatted properties for file info, TMDB data, metadata extraction, media info extraction, and filename extraction. - Bumped version to 0.6.5 in `uv.lock`.
56 lines
1.6 KiB
Python
56 lines
1.6 KiB
Python
"""Track formatting decorators.
|
|
|
|
Provides decorator versions of TrackFormatter methods.
|
|
"""
|
|
|
|
from functools import wraps
|
|
from typing import Callable
|
|
from .track_formatter import TrackFormatter
|
|
|
|
|
|
class TrackDecorators:
|
|
"""Track formatting decorators."""
|
|
|
|
@staticmethod
|
|
def video_track() -> Callable:
|
|
"""Decorator to format video track data."""
|
|
def decorator(func: Callable) -> Callable:
|
|
@wraps(func)
|
|
def wrapper(*args, **kwargs):
|
|
result = func(*args, **kwargs)
|
|
if not result:
|
|
return ""
|
|
return TrackFormatter.format_video_track(result)
|
|
return wrapper
|
|
return decorator
|
|
|
|
@staticmethod
|
|
def audio_track() -> Callable:
|
|
"""Decorator to format audio track data."""
|
|
def decorator(func: Callable) -> Callable:
|
|
@wraps(func)
|
|
def wrapper(*args, **kwargs):
|
|
result = func(*args, **kwargs)
|
|
if not result:
|
|
return ""
|
|
return TrackFormatter.format_audio_track(result)
|
|
return wrapper
|
|
return decorator
|
|
|
|
@staticmethod
|
|
def subtitle_track() -> Callable:
|
|
"""Decorator to format subtitle track data."""
|
|
def decorator(func: Callable) -> Callable:
|
|
@wraps(func)
|
|
def wrapper(*args, **kwargs):
|
|
result = func(*args, **kwargs)
|
|
if not result:
|
|
return ""
|
|
return TrackFormatter.format_subtitle_track(result)
|
|
return wrapper
|
|
return decorator
|
|
|
|
|
|
# Singleton instance
|
|
track_decorators = TrackDecorators()
|