refactor(tracks): name and match resolutions by one standard-height rule

standard_resolution() replaces the aspect-ratio logic in naming and is shared by -q matching, export names and progress/hybrid labels, so 1920x1088, 1916x1076, portrait and DCI sizes get standard names.
This commit is contained in:
imSp4rky
2026-10-31 22:05:26 -06:00
parent d5a8ed2a39
commit 86f26c31d5
13 changed files with 190 additions and 84 deletions
+3 -9
View File
@@ -15,9 +15,8 @@ from typing import Any, Optional
from unshackle.core.constants import AnyTrack
from unshackle.core.titles import Episode, Movie, Song, Title_T
from unshackle.core.tracks import Audio, Video
from unshackle.core.utilities import sanitize_filename
from unshackle.core.utilities import sanitize_filename, standard_resolution
STANDARD_HEIGHTS = (4320, 2160, 1440, 1080, 720, 576, 480, 360)
MANIFEST_ORDER = (Video.Descriptor.DASH, Video.Descriptor.HLS, Video.Descriptor.ISM, Video.Descriptor.URL)
MAX_SCOPE_PARTS = 3
MAX_TITLE_LENGTH = 100
@@ -107,13 +106,8 @@ def scope_part(titles: Sequence[Title_T], seasons: Mapping[int, Collection[int]]
def resolution(track: Video) -> Optional[int]:
"""The resolution a release name uses: a letterboxed 1920x800 is 1080p, from its width."""
if not track.height:
return None
height = track.height
if track.width and track.width > height:
height = max(height, track.width * 9 // 16)
return next((std for std in STANDARD_HEIGHTS if abs(height - std) <= 16), height)
"""The resolution a release name uses, the same as the {resolution} template variable."""
return standard_resolution(track.width, track.height) if track.height else None
def audio_token(track: Audio) -> str: