diff options
author | Jaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com> | 2014-11-19 23:33:28 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-11-20 00:17:13 +0100 |
commit | cf8efe32351c745903cc3b3bf0b8bc0f33d5cfd5 (patch) | |
tree | 119ee7efcb3e32aa67df965ec497e6e227d56ae7 /player/lua/ytdl_hook.lua | |
parent | bf2eb51d6802824606e72ad2e8ada753bbaaaef1 (diff) | |
download | mpv-cf8efe32351c745903cc3b3bf0b8bc0f33d5cfd5.tar.bz2 mpv-cf8efe32351c745903cc3b3bf0b8bc0f33d5cfd5.tar.xz |
options: add --ytdl-format option for youtube-dl format
It's passed with the '--format' option to youtube-dl.
If it isn't set, we don't pass '--format best' so that youtube-dl can
use the options from its configuration file.
Signed-off-by: wm4 <wm4@nowhere>
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 ...") |