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.
This commit is contained in:
Christoph Heinrich 2022-07-11 20:28:05 +02:00 committed by Leo Izen
parent 3875312e41
commit 1a633a6cbc
1 changed files with 7 additions and 1 deletions

View File

@ -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,