mirror of https://github.com/mpv-player/mpv
ytdl_hook: actually load the script-opts
Also, comma-separated list doesn't actually work, even quote-surrounded. Switch to using | instead.
This commit is contained in:
parent
042e98f4c9
commit
db60cbb80a
|
@ -531,12 +531,12 @@ Program Behavior
|
|||
|
||||
If the script can't do anything with an URL, it will do nothing.
|
||||
|
||||
The `exclude` script option accepts a comma-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
|
||||
the ``http(s)://`` part of the URL.
|
||||
|
||||
``^`` matches the beginning of the URL, ``$`` matches its end, and you
|
||||
should use ``%`` before any of the characters ``^$()%,.[]*+-?`` to match
|
||||
should use ``%`` before any of the characters ``^$()%|,.[]*+-?`` to match
|
||||
that character.
|
||||
|
||||
.. admonition:: Example
|
||||
|
@ -544,7 +544,7 @@ Program Behavior
|
|||
``--script-opts=ytdl_hook-exclude='^youtube%.com'`` will exclude any
|
||||
URL that starts with ``http://youtube.com`` or
|
||||
``https://youtube.com``.
|
||||
``--script-opts=ytdl_hook-exclude='%.mkv$,%.mp4$'`` will exclude any
|
||||
``--script-opts=ytdl_hook-exclude='%.mkv$|%.mp4$'`` will exclude any
|
||||
URL that ends with ``.mkv`` or ``.mp4``.
|
||||
|
||||
See more `lua patterns here`__.
|
||||
|
|
|
@ -5,6 +5,7 @@ local options = require 'mp.options'
|
|||
local o = {
|
||||
exclude = ""
|
||||
}
|
||||
options.read_options(o)
|
||||
|
||||
local ytdl = {
|
||||
path = "youtube-dl",
|
||||
|
@ -100,12 +101,12 @@ local function extract_chapters(data, video_length)
|
|||
end
|
||||
|
||||
local function is_blacklisted(url)
|
||||
if o.blacklist == "" then return false end
|
||||
if o.exclude == "" then return false end
|
||||
if #ytdl.blacklisted == 0 then
|
||||
local joined = o.blacklist
|
||||
while joined:match(',?[^,]+') do
|
||||
local _, e, domain = joined:find(',?([^,]+)')
|
||||
table.insert(ytdl.blacklisted, domain)
|
||||
local joined = o.exclude
|
||||
while joined:match('%|?[^|]+') do
|
||||
local _, e, substring = joined:find('%|?([^|]+)')
|
||||
table.insert(ytdl.blacklisted, substring)
|
||||
joined = joined:sub(e+1)
|
||||
end
|
||||
end
|
||||
|
@ -113,6 +114,7 @@ local function is_blacklisted(url)
|
|||
url = url:match('https?://(.+)')
|
||||
for _, exclude in ipairs(ytdl.blacklisted) do
|
||||
if url:match(exclude) then
|
||||
msg.verbose('URL matches excluded substring. Skipping.')
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue