0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 12:02:23 +02:00

ytdl_hook: improve Windows exe search with suffix

This commit is contained in:
fireattack 2023-08-13 13:10:27 +08:00 committed by Dudemanguy
parent 598e30173d
commit 3954660f03
2 changed files with 4 additions and 4 deletions

View File

@ -945,7 +945,7 @@ Program Behavior
paths should be separated by : on Unix and ; on Windows. mpv looks in
order for the configured paths in PATH and in mpv's config directory.
The defaults are "yt-dlp", "yt-dlp_x86" and "youtube-dl". On Windows
the suffix extension ".exe" is always appended.
the suffix extension is not necessary, but only ".exe" is acceptable.
.. admonition:: Why do the option names mix ``_`` and ``-``?

View File

@ -834,7 +834,7 @@ function run_ytdl_hook(url)
for _, path in pairs(ytdl.paths_to_search) do
-- search for youtube-dl in mpv's config dir
local exesuf = platform_is_windows() and ".exe" or ""
local exesuf = platform_is_windows() and not path:lower():match("%.exe$") and ".exe" or ""
local ytdl_cmd = mp.find_config_file(path .. exesuf)
if ytdl_cmd then
msg.verbose("Found youtube-dl at: " .. ytdl_cmd)
@ -847,9 +847,9 @@ function run_ytdl_hook(url)
command[1] = path
result = exec(command)
if result.error_string == "init" then
msg.verbose("youtube-dl with path " .. path .. exesuf .. " not found in PATH or not enough permissions")
msg.verbose("youtube-dl with path " .. path .. " not found in PATH or not enough permissions")
else
msg.verbose("Found youtube-dl with path " .. path .. exesuf .. " in PATH")
msg.verbose("Found youtube-dl with path " .. path .. " in PATH")
ytdl.path = path
break
end