mirror of
https://github.com/shadoll/moma.git
synced 2026-08-28 11:33:25 +00:00
Add decorators for formatting various media attributes
- 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`.
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
"""Resolution formatting decorators.
|
||||
|
||||
Provides decorator versions of ResolutionFormatter methods.
|
||||
"""
|
||||
|
||||
from functools import wraps
|
||||
from typing import Callable
|
||||
from .resolution_formatter import ResolutionFormatter
|
||||
|
||||
|
||||
class ResolutionDecorators:
|
||||
"""Resolution formatting decorators."""
|
||||
|
||||
@staticmethod
|
||||
def resolution_dimensions() -> Callable:
|
||||
"""Decorator to format resolution as dimensions (WxH)."""
|
||||
def decorator(func: Callable) -> Callable:
|
||||
@wraps(func)
|
||||
def wrapper(*args, **kwargs):
|
||||
result = func(*args, **kwargs)
|
||||
if not result:
|
||||
return ""
|
||||
return ResolutionFormatter.format_resolution_dimensions(result)
|
||||
return wrapper
|
||||
return decorator
|
||||
|
||||
|
||||
# Singleton instance
|
||||
resolution_decorators = ResolutionDecorators()
|
||||
Reference in New Issue
Block a user