mpv select first subtitle

This commit is contained in:
rydesun 2022-07-09 14:08:55 +08:00
parent c095cdd1c0
commit a9a8c5500b

View file

@ -28,11 +28,17 @@ local function add_subtitles(dir, prefix)
local res = utils.subprocess({args=cmd})
local prefix_lower = prefix:lower()
local selected = false
for subtitle_path in res.stdout:gmatch("[^\r\n]+") do
local _, subtitle_name = utils.split_path(subtitle_path)
if subtitle_name:lower():find(user_opts.subtitle_pattern) or
subtitle_name:lower():find(prefix_lower, 1, true) == 1 then
mp.commandv('sub-add', subtitle_path, 'select')
if selected then
mp.commandv('sub-add', subtitle_path, 'auto')
else
mp.commandv('sub-add', subtitle_path, 'select')
selected = true
end
end
end
end