diff options
-rw-r--r-- | DOCS/man/options.rst | 7 | ||||
-rw-r--r-- | options/options.c | 2 | ||||
-rw-r--r-- | player/lua/ytdl_hook.lua | 22 |
3 files changed, 15 insertions, 16 deletions
diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst index 6038b18d33..e230ad2adc 100644 --- a/DOCS/man/options.rst +++ b/DOCS/man/options.rst @@ -456,16 +456,13 @@ Program Behavior If the script can't do anything with an URL, it will do nothing. - (Note: this is the replacement for the now removed libquvi support.) - ``--ytdl-format=<best|worst|mp4|webm|...>`` Video format/quality that is directly passed to youtube-dl. The possible values are specific to the website and the video, for a given url the available formats can be found with the command ``youtube-dl --list-formats URL``. See youtube-dl's documentation for - available aliases. To use experimental DASH support for youtube, use - ``bestvideo+bestaudio``. - (Default: ``best``) + available aliases. + (Default: youtube-dl's default, currently ``bestvideo+bestaudio/best``) ``--ytdl-raw-options=<key>=<value>[,<key>=<value>[,...]]`` Pass arbitrary options to youtube-dl. Parameter and argument should be diff --git a/options/options.c b/options/options.c index 51d2c5ca82..7a23e0c9c2 100644 --- a/options/options.c +++ b/options/options.c @@ -717,7 +717,7 @@ const struct MPOpts mp_default_opts = { #if HAVE_LUA .lua_load_osc = 1, .lua_load_ytdl = 1, - .lua_ytdl_format = "best", + .lua_ytdl_format = NULL, .lua_ytdl_raw_options = NULL, #endif .auto_load_scripts = 1, diff --git a/player/lua/ytdl_hook.lua b/player/lua/ytdl_hook.lua index 66ab85159b..d43a7bb35e 100644 --- a/player/lua/ytdl_hook.lua +++ b/player/lua/ytdl_hook.lua @@ -2,7 +2,8 @@ local utils = require 'mp.utils' local msg = require 'mp.msg' local ytdl = { - path = "youtube-dl" + path = "youtube-dl", + searched = false } local function exec(args) @@ -60,6 +61,16 @@ mp.add_hook("on_load", 10, function () if (url:find("http://") == 1) or (url:find("https://") == 1) or (url:find("ytdl://") == 1) then + -- check for youtube-dl in mpv's config dir + if not (ytdl.searched) then + local ytdl_mcd = mp.find_config_file("youtube-dl") + if not (ytdl_mcd == nil) then + msg.verbose("found youtube-dl at: " .. ytdl_mcd) + ytdl.path = ytdl_mcd + end + ytdl.searched = true + end + -- strip ytdl:// if (url:find("ytdl://") == 1) then url = url:sub(8) @@ -183,19 +194,10 @@ mp.add_hook("on_load", 10, function () -- video url streamurl = json["requested_formats"][1].url - if (json["ext"] == "mp4") and not (json.duration == nil) then - msg.info("Using DASH, expect inaccurate duration.") - msg.info("Actual duration: "..mp.format_time(json.duration)) - end - -- audio url mp.set_property("file-local-options/audio-file", json["requested_formats"][2].url) - -- workaround for slow startup (causes inaccurate duration) - mp.set_property("file-local-options/demuxer-lavf-o", - "fflags=+ignidx") - elseif not (json.url == nil) then -- normal video streamurl = json.url |