diff options
author | Christoph Heinrich <christoph.heinrich@student.tugraz.at> | 2022-07-11 20:28:05 +0200 |
---|---|---|
committer | Leo Izen <leo.izen@gmail.com> | 2022-11-01 09:54:33 -0400 |
commit | 1a633a6cbccb72e7bb1fb64894799bb4bac53026 (patch) | |
tree | 69bef98018b1b3a87b52d84022b69461e14b4828 /player/lua/ytdl_hook.lua | |
parent | 3875312e41e38380860357fc0e9fd0290fd0a2b4 (diff) | |
download | mpv-1a633a6cbccb72e7bb1fb64894799bb4bac53026.tar.bz2 mpv-1a633a6cbccb72e7bb1fb64894799bb4bac53026.tar.xz |
ytdl_hook: reverse order of tracks
Only matters when configuring ytdl_hook with `all_formats=yes`.
So far the tracks were ordered from worst to best quality.
Web players with quality selection always show the highest quality
option at the top. Since tracks are usually listed with the first
track at the top, that should also be the highest quality one.
yt-dlp/youtube-dl sorts it's formats from worst to best.
Iterate in reverse to get best track first.
Diffstat (limited to 'player/lua/ytdl_hook.lua')
-rw-r--r-- | player/lua/ytdl_hook.lua | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/player/lua/ytdl_hook.lua b/player/lua/ytdl_hook.lua index 57023e224e..f40579ad36 100644 --- a/player/lua/ytdl_hook.lua +++ b/player/lua/ytdl_hook.lua @@ -409,7 +409,13 @@ local function formats_to_edl(json, formats, use_all_formats) local has_requested_video = false local has_requested_audio = false - for index, track in ipairs(formats) do + -- Web players with quality selection always show the highest quality + -- option at the top. Since tracks are usually listed with the first + -- track at the top, that should also be the highest quality track. + -- yt-dlp/youtube-dl sorts it's formats from worst to best. + -- Iterate in reverse to get best track first. + for index = #formats, 1, -1 do + local track = formats[index] local edl_track = nil edl_track = edl_track_joined(track.fragments, track.protocol, json.is_live, |