diff options
Diffstat (limited to 'player/lua/ytdl_hook.lua')
-rw-r--r-- | player/lua/ytdl_hook.lua | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/player/lua/ytdl_hook.lua b/player/lua/ytdl_hook.lua index 8f3c319758..143ca4fe7a 100644 --- a/player/lua/ytdl_hook.lua +++ b/player/lua/ytdl_hook.lua @@ -55,16 +55,25 @@ mp.add_hook("on_load", 10, function () url = url:sub(8) end + local format = mp.get_property("options/ytdl-format") + -- subformat workaround local subformat = "srt" if url:find("crunchyroll.com") then subformat = "ass" end - local es, json = exec({ + local command = { ytdl.path, "-J", "--flat-playlist", "--all-subs", - "--sub-format", subformat, "--no-playlist", "--", url - }) + "--sub-format", subformat, "--no-playlist" + } + if (format ~= "") then + table.insert(command, "--format") + table.insert(command, format) + end + table.insert(command, "--") + table.insert(command, url) + local es, json = exec(command) if (es < 0) or (json == nil) or (json == "") then msg.warn("youtube-dl failed, trying to play URL directly ...") |