Skip to content

Commit

Permalink
ytdl_hook: support alternative youtube-dl path
Browse files Browse the repository at this point in the history
Allows using a youtube-dl not in PATH or a compatible fork of
youtube-dl.
  • Loading branch information
wiiaboo committed Oct 27, 2020
1 parent c07089a commit 93f84b5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions DOCS/man/options.rst
Expand Up @@ -954,6 +954,11 @@ Program Behavior
if available, allowing for video/audio selection in runtime (default:
no). It's disabled ("no") by default for performance reasons.

``ytdl_path=youtube-dl``
Configure path to youtube-dl executable or a compatible fork's.
The default "youtube-dl" looks for the executable in PATH. In a Windows
environment the suffix extension ".exe" is always appended.

.. admonition:: Why do the option names mix ``_`` and ``-``?

I have no idea.
Expand Down
6 changes: 4 additions & 2 deletions player/lua/ytdl_hook.lua
Expand Up @@ -8,16 +8,18 @@ local o = {
use_manifests = false,
all_formats = false,
force_all_formats = true,
ytdl_path = "youtube-dl",
}

local ytdl = {
path = "youtube-dl",
path = nil,
searched = false,
blacklisted = {}
}

options.read_options(o, nil, function()
ytdl.blacklisted = {} -- reparse o.exclude next time
ytdl.searched = false
end)

local chapter_list = {}
Expand Down Expand Up @@ -690,7 +692,7 @@ function run_ytdl_hook(url)
-- check for youtube-dl in mpv's config dir
if not (ytdl.searched) then
local exesuf = (package.config:sub(1,1) == '\\') and '.exe' or ''
local ytdl_mcd = mp.find_config_file("youtube-dl" .. exesuf)
local ytdl_mcd = mp.find_config_file(o.ytdl_path .. exesuf)
if not (ytdl_mcd == nil) then
msg.verbose("found youtube-dl at: " .. ytdl_mcd)
ytdl.path = ytdl_mcd
Expand Down

0 comments on commit 93f84b5

Please sign in to comment.