Spaces:
Sleeping
Sleeping
| """Audio quality value object.""" | |
| from dataclasses import dataclass | |
| from typing import Dict, Any | |
| from ..exceptions.domain_exceptions import InvalidQualityLevelError | |
| class AudioQuality: | |
| """Value object representing audio quality level.""" | |
| value: str | |
| LEVELS = { | |
| 'high': {'priority': 3, 'description': 'Best quality, larger file size'}, | |
| 'medium': {'priority': 2, 'description': 'Balanced quality and file size'}, | |
| 'low': {'priority': 1, 'description': 'Smaller file size, acceptable quality'} | |
| } | |
| def __post_init__(self): | |
| if self.value.lower() not in self.LEVELS: | |
| raise InvalidQualityLevelError(self.value) | |
| # Normalize to lowercase | |
| object.__setattr__(self, 'value', self.value.lower()) | |
| def priority(self) -> int: | |
| """Get numeric priority (higher is better quality).""" | |
| return self.LEVELS[self.value]['priority'] | |
| def description(self) -> str: | |
| """Get human-readable description.""" | |
| return self.LEVELS[self.value]['description'] | |
| def get_settings_for_format(self, audio_format: 'AudioFormat', | |
| quality_presets: Dict[str, Dict[str, Dict[str, Any]]]) -> Dict[str, Any]: | |
| """Get quality settings for specific audio format.""" | |
| return quality_presets.get(audio_format.value, {}).get(self.value, {}) | |
| def __str__(self) -> str: | |
| return self.value | |
| def __lt__(self, other: 'AudioQuality') -> bool: | |
| """Compare quality levels by priority.""" | |
| return self.priority < other.priority |