mirror of
https://github.com/shadoll/moma.git
synced 2026-08-28 03:27:34 +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`.
43 lines
1.2 KiB
Python
43 lines
1.2 KiB
Python
"""Duration formatting decorators.
|
|
|
|
Provides decorator versions of DurationFormatter methods.
|
|
"""
|
|
|
|
from functools import wraps
|
|
from typing import Callable
|
|
from .duration_formatter import DurationFormatter
|
|
|
|
|
|
class DurationDecorators:
|
|
"""Duration formatting decorators."""
|
|
|
|
@staticmethod
|
|
def duration_full() -> Callable:
|
|
"""Decorator to format duration in full format (HH:MM:SS)."""
|
|
def decorator(func: Callable) -> Callable:
|
|
@wraps(func)
|
|
def wrapper(*args, **kwargs):
|
|
result = func(*args, **kwargs)
|
|
if not result:
|
|
return ""
|
|
return DurationFormatter.format_full(result)
|
|
return wrapper
|
|
return decorator
|
|
|
|
@staticmethod
|
|
def duration_short() -> Callable:
|
|
"""Decorator to format duration in short format."""
|
|
def decorator(func: Callable) -> Callable:
|
|
@wraps(func)
|
|
def wrapper(*args, **kwargs):
|
|
result = func(*args, **kwargs)
|
|
if not result:
|
|
return ""
|
|
return DurationFormatter.format_short(result)
|
|
return wrapper
|
|
return decorator
|
|
|
|
|
|
# Singleton instance
|
|
duration_decorators = DurationDecorators()
|