mirror of https://github.com/mpv-player/mpv
ytdl_hook: add script option to revert to trying youtube-dl first
Should only make a difference if most of the URLs you open need youtube-dl parsing.
This commit is contained in:
parent
5103b5dc2c
commit
87d3af6f19
|
@ -552,6 +552,11 @@ Program Behavior
|
||||||
|
|
||||||
If the script can't do anything with an URL, it will do nothing.
|
If the script can't do anything with an URL, it will do nothing.
|
||||||
|
|
||||||
|
The `try_ytdl_first` script option accepts a boolean 'yes' or 'no', and if
|
||||||
|
'yes' will try parsing the URL with youtube-dl first, instead of the default
|
||||||
|
where it's only after mpv failed to open it. This mostly depends on whether
|
||||||
|
most of your URLs need youtube-dl parsing.
|
||||||
|
|
||||||
The `exclude` script option accepts a ``|``-separated list of URL patterns
|
The `exclude` script option accepts a ``|``-separated list of URL patterns
|
||||||
which mpv should not use with youtube-dl. The patterns are matched after
|
which mpv should not use with youtube-dl. The patterns are matched after
|
||||||
the ``http(s)://`` part of the URL.
|
the ``http(s)://`` part of the URL.
|
||||||
|
|
|
@ -3,7 +3,8 @@ local msg = require 'mp.msg'
|
||||||
local options = require 'mp.options'
|
local options = require 'mp.options'
|
||||||
|
|
||||||
local o = {
|
local o = {
|
||||||
exclude = ""
|
exclude = "",
|
||||||
|
try_ytdl_first = false
|
||||||
}
|
}
|
||||||
options.read_options(o)
|
options.read_options(o)
|
||||||
|
|
||||||
|
@ -301,7 +302,7 @@ local function add_single_video(json)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
mp.add_hook("on_load_fail", 10, function ()
|
mp.add_hook(try_ytdl_first and "on_load" or "on_load_fail", 10, function ()
|
||||||
local url = mp.get_property("stream-open-filename")
|
local url = mp.get_property("stream-open-filename")
|
||||||
local start_time = os.clock()
|
local start_time = os.clock()
|
||||||
if (url:find("ytdl://") == 1) or
|
if (url:find("ytdl://") == 1) or
|
||||||
|
|
Loading…
Reference in New Issue