1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-23 07:12:39 +00:00

ytdl: add "--ytdl-params" option

This option allows the user to pass non-supported options directly to
youtube-dl, such as "--proxy URL", "--username USERNAME" and
'--password PASSWORD".

There is no sanity checking so it's possible to break things (i.e.
if you pass "--version" mpv exits with random JSON error).

Signed-off-by: wm4 <wm4@nowhere>
This commit is contained in:
Thiago Kenji Okada 2015-02-22 17:32:42 -03:00 committed by wm4
parent e85bcc1223
commit 633147c959
4 changed files with 22 additions and 0 deletions

View File

@ -454,6 +454,18 @@ Program Behavior
``bestvideo+bestaudio``.
(Default: ``best``)
``--ytdl-raw-options=<key>=<value>[,<key>=<value>[,...]]``
Pass arbitraty options to youtube-dl. Parameter and argument should be
passed as a key-value pair. Options without argument must include ``=``.
There is no sanity checking so it's possible to break things (i.e.
passing invalid parameters to youtube-dl).
.. admonition:: Example
``--ytdl-raw-options=username=user,password=pass``
``--ytdl-raw-options=force-ipv6=``
Video
-----

View File

@ -133,6 +133,7 @@ const m_option_t mp_opts[] = {
OPT_FLAG("osc", lua_load_osc, CONF_GLOBAL),
OPT_FLAG("ytdl", lua_load_ytdl, CONF_GLOBAL),
OPT_STRING("ytdl-format", lua_ytdl_format, CONF_GLOBAL),
OPT_KEYVALUELIST("ytdl-raw-options", lua_ytdl_raw_options, CONF_GLOBAL),
OPT_FLAG("load-scripts", auto_load_scripts, CONF_GLOBAL),
#endif
@ -716,6 +717,7 @@ const struct MPOpts mp_default_opts = {
.lua_load_osc = 1,
.lua_load_ytdl = 1,
.lua_ytdl_format = NULL,
.lua_ytdl_raw_options = NULL,
#endif
.auto_load_scripts = 1,
.loop_times = 1,

View File

@ -68,6 +68,7 @@ typedef struct MPOpts {
int lua_load_osc;
int lua_load_ytdl;
char *lua_ytdl_format;
char **lua_ytdl_raw_options;
int auto_load_scripts;

View File

@ -80,6 +80,7 @@ mp.add_hook("on_load", 10, function ()
end
local format = mp.get_property("options/ytdl-format")
local raw_options = mp.get_property_native("options/ytdl-raw-options")
-- subformat workaround
local subformat = "ass/srt/best"
@ -92,6 +93,12 @@ mp.add_hook("on_load", 10, function ()
table.insert(command, "--format")
table.insert(command, format)
end
for param, arg in pairs(raw_options) do
table.insert(command, "--" .. param)
if (arg ~= "") then
table.insert(command, arg)
end
end
table.insert(command, "--")
table.insert(command, url)
local es, json = exec(command)