++ fix available resolution

This commit is contained in:
2026-01-10 14:40:37 +01:00
parent cc8bb74657
commit 0b6ce3134b
2 changed files with 9 additions and 0 deletions

View File

@@ -42,6 +42,7 @@ def _filter_video_formats(formats: List[Dict]) -> List[Dict]:
for f in formats:
if f.get("vcodec") == "none":
continue
height = f.get("height") or 0
resolution = None
if f.get("height") and f.get("width"):
resolution = f"{f['height']}p"
@@ -53,8 +54,11 @@ def _filter_video_formats(formats: List[Dict]) -> List[Dict]:
"resolution": resolution,
"fps": f.get("fps"),
"size": _format_size(f.get("filesize")),
"height": height,
}
)
# Sort by height descending, put formats without height at the end
videos.sort(key=lambda x: (x["height"] if x["height"] > 0 else -1), reverse=True)
return videos