mirror of
https://github.com/mpv-player/mpv
synced 2024-12-28 01:52:19 +00:00
ytdl_hook: sort subtitle list by language
The subtitle list is returned in randomized order, because a table (i.e. JSON object) is used. To make the order stable across repeated invocations, sort it by language.
This commit is contained in:
parent
69c6b244a1
commit
5dcfe32ff2
@ -577,7 +577,13 @@ local function add_single_video(json)
|
||||
|
||||
-- add subtitles
|
||||
if not (json.requested_subtitles == nil) then
|
||||
for lang, sub_info in pairs(json.requested_subtitles) do
|
||||
local subs = {}
|
||||
for lang, info in pairs(json.requested_subtitles) do
|
||||
subs[#subs + 1] = {lang = lang or "-", info = info}
|
||||
end
|
||||
table.sort(subs, function(a, b) return a.lang < b.lang end)
|
||||
for _, e in ipairs(subs) do
|
||||
local lang, sub_info = e.lang, e.info
|
||||
msg.verbose("adding subtitle ["..lang.."]")
|
||||
|
||||
local sub = nil
|
||||
|
Loading…
Reference in New Issue
Block a user