From 0b6ce3134b998cd16366f511e7a7d446f085b5cf Mon Sep 17 00:00:00 2001 From: Francesco Picone Date: Sat, 10 Jan 2026 14:40:37 +0100 Subject: [PATCH] ++ fix available resolution --- api/app.py | 4 ++++ frontend/main.js | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/api/app.py b/api/app.py index a69101b..2f7e246 100644 --- a/api/app.py +++ b/api/app.py @@ -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 diff --git a/frontend/main.js b/frontend/main.js index 02e4a45..dab0b69 100644 --- a/frontend/main.js +++ b/frontend/main.js @@ -68,6 +68,11 @@ async function fetchInfo() { return `${f.ext} ${abr}${size}`; }); + // Auto-select highest resolution (first video format) + if (lastFormats.video.length > 0) { + videoSelect.value = lastFormats.video[0].id; + } + audioExt.disabled = false; const minutes = data.duration ? Math.round(data.duration / 60) : '?';