fix(tracks): match resolutions per range and codec

An exact height match in one range denied the 16:9 canvas fallback to the others, so a cropped HDR10 or SDR track was dropped whenever an uncropped DV track matched the requested height. Also sweep the hybrid L5 temp files so a killed run cannot leave a stale RPU behind.
This commit is contained in:
imSp4rky
2026-08-27 14:32:36 -06:00
parent dcc1c8af18
commit 4ef577c1d1
4 changed files with 44 additions and 16 deletions
+10 -1
View File
@@ -3473,7 +3473,16 @@ class dl:
temp_path.unlink(missing_ok=True)
except PermissionError:
self.log.warning(f"Failed to delete temp file (in use?): {temp_path}")
for leftover in ("HDR10-DV.hevc", "DV.hevc", "RPU.bin", "RPU_UNT.bin", "RPU_L6.bin"):
for leftover in (
"HDR10-DV.hevc",
"HDR10.hevc",
"DV.hevc",
"RPU.bin",
"RPU_UNT.bin",
"RPU_L5.bin",
"RPU_L6.bin",
"L5.json",
):
leftover_path = config.directories.temp / leftover
try:
leftover_path.unlink(missing_ok=True)
+11 -12
View File
@@ -455,19 +455,18 @@ class Tracks:
return select
def by_resolutions(self, resolutions: list[int], per_resolution: int = 0) -> None:
# Note: Do not merge these list comprehensions. They must be done separately so the results
# from the 16:9 canvas check is only used if there's no exact height resolution match.
selected = []
groups: dict[tuple, list[Video]] = {}
for video in self.videos:
groups.setdefault((video.range, video.codec), []).append(video)
keep: set[int] = set()
for resolution in resolutions:
matches = [ # exact matches
x for x in self.videos if x.height == resolution
]
if not matches:
matches = [ # 16:9 canvas matches
x for x in self.videos if x.width and int(x.width * (9 / 16)) == resolution
]
selected.extend(matches[: per_resolution or None])
self.videos = selected
for group in groups.values():
matches = [x for x in group if x.height == resolution]
if not matches:
matches = [x for x in group if x.width and int(x.width * (9 / 16)) == resolution]
keep.update(id(x) for x in matches[: per_resolution or None])
self.videos = [x for x in self.videos if id(x) in keep]
@staticmethod
def by_language(