e07c9ec77b
Several weeks of work accumulated without being committed. Grouped here for clarity; see CHANGELOG.md [Unreleased] for the user-facing summary. Highlights ---------- P1 #2 — ISO 639-2/B canonical migration - New Language VO + LanguageRegistry (alfred/domain/shared/knowledge/). - iso_languages.yaml as single source of truth for language codes. - SubtitleKnowledgeBase now delegates lookup to LanguageRegistry; subtitles.yaml only declares subtitle-specific tokens (vostfr, vf, vff, …). - SubtitlePreferences default → ["fre", "eng"]; subtitle filenames written as {iso639_2b}.srt (legacy fr.srt still read via alias). - Scanner: dropped _LANG_KEYWORDS / _SDH_TOKENS / _FORCED_TOKENS / SUBTITLE_EXTENSIONS hardcoded dicts. - Fixed: 'hi' token no longer marks SDH (conflicted with Hindi alias). - Added settings.min_movie_size_bytes (was a module constant). P1 #3 — Release parser unification + data-driven tokenizer - parse_release() is now the single source of truth for release-name parsing. - alfred/knowledge/release/separators.yaml declares the token separators used by the tokenizer (., space, [, ], (, ), _). New conventions can be added without code changes. - Tokenizer now splits on any configured separator instead of name.split('.'). Releases like 'The Father (2020) [1080p] [WEBRip] [5.1] [YTS.MX]' parse via the direct path without sanitization fallback. - Site-tag extraction always runs first; well-formedness only rejects truly forbidden chars. - _parse_season_episode() extended with NxNN / NxNNxNN alt forms. - Removed dead helpers: _sanitize, _normalize. Domain cleanup - Deleted fossil services with zero production callers: alfred/domain/movies/services.py alfred/domain/tv_shows/services.py alfred/domain/subtitles/services.py (replaced by subtitles/services/ package) alfred/domain/subtitles/repositories.py - Split monolithic subtitle services into a package (identifier, matcher, placer, pattern_detector, utils) + dedicated knowledge/ package. - MediaInfo split into dedicated package (alfred/domain/shared/media/: audio, video, subtitle, info, matching). Persistence cleanup - Removed dead JSON repositories (movie/subtitle/tvshow_repository.py). Tests - Major expansion of the test suite organized to mirror the source tree. - Removed obsolete *_edge_cases test files superseded by structured tests. - Suite: 990 passed, 8 skipped. Misc - .gitignore: exclude env_backup/ and *.bak. - Adjustments across agent/llm, app.py, application/filesystem, and infrastructure/filesystem to align with the new domain layout.
63 lines
2.0 KiB
Python
63 lines
2.0 KiB
Python
"""VideoTrack — a single video stream as reported by ffprobe."""
|
||
|
||
from __future__ import annotations
|
||
|
||
from dataclasses import dataclass
|
||
|
||
|
||
@dataclass
|
||
class VideoTrack:
|
||
"""A single video track as reported by ffprobe.
|
||
|
||
A media file typically has one video track but can have several (alt
|
||
camera angles, attached thumbnail images reported as still-image streams,
|
||
etc.), hence the list[VideoTrack] on MediaInfo.
|
||
"""
|
||
|
||
index: int
|
||
codec: str | None # h264, hevc, av1, …
|
||
width: int | None
|
||
height: int | None
|
||
is_default: bool = False
|
||
|
||
@property
|
||
def resolution(self) -> str | None:
|
||
"""
|
||
Best-effort resolution string: 2160p, 1080p, 720p, …
|
||
|
||
Width takes priority over height to handle widescreen/cinema crops
|
||
(e.g. 1920×960 scope → 1080p, not 720p). Falls back to height when
|
||
width is unavailable.
|
||
"""
|
||
match (self.width, self.height):
|
||
case (None, None):
|
||
return None
|
||
case (w, h) if w is not None:
|
||
match True:
|
||
case _ if w >= 3840:
|
||
return "2160p"
|
||
case _ if w >= 1920:
|
||
return "1080p"
|
||
case _ if w >= 1280:
|
||
return "720p"
|
||
case _ if w >= 720:
|
||
return "576p"
|
||
case _ if w >= 640:
|
||
return "480p"
|
||
case _:
|
||
return f"{h}p" if h else f"{w}w"
|
||
case (None, h):
|
||
match True:
|
||
case _ if h >= 2160:
|
||
return "2160p"
|
||
case _ if h >= 1080:
|
||
return "1080p"
|
||
case _ if h >= 720:
|
||
return "720p"
|
||
case _ if h >= 576:
|
||
return "576p"
|
||
case _ if h >= 480:
|
||
return "480p"
|
||
case _:
|
||
return f"{h}p"
|