mirror of https://github.com/mpv-player/mpv
ytdl_hook.lua: fix lint warnings
This commit is contained in:
parent
fe760f2b8a
commit
62868beffe
|
@ -110,7 +110,6 @@ max_line_length = 100
|
|||
-- TODO: Remove everything below this line
|
||||
local todo = {
|
||||
"player/lua/osc.lua",
|
||||
"player/lua/ytdl_hook.lua",
|
||||
"TOOLS/lua/ao-null-reload.lua",
|
||||
"TOOLS/lua/autocrop.lua",
|
||||
"TOOLS/lua/autodeint.lua",
|
||||
|
|
|
@ -27,14 +27,14 @@ end)
|
|||
local chapter_list = {}
|
||||
local playlist_cookies = {}
|
||||
|
||||
function Set (t)
|
||||
local function Set (t)
|
||||
local set = {}
|
||||
for _, v in pairs(t) do set[v] = true end
|
||||
return set
|
||||
end
|
||||
|
||||
-- ?: surrogate (keep in mind that there is no lazy evaluation)
|
||||
function iif(cond, if_true, if_false)
|
||||
local function iif(cond, if_true, if_false)
|
||||
if cond then
|
||||
return if_true
|
||||
end
|
||||
|
@ -766,8 +766,9 @@ local function add_single_video(json)
|
|||
msg.verbose("adding thumbnail")
|
||||
mp.commandv("video-add", thumb_info.url, "auto")
|
||||
thumb_height = 0
|
||||
elseif (thumb_preference ~= nil and (thumb_info.preference or -math.huge) > thumb_preference) or
|
||||
(thumb_preference == nil and ((thumb_info.height or 0) > thumb_height)) then
|
||||
elseif (thumb_preference ~= nil and
|
||||
(thumb_info.preference or -math.huge) > thumb_preference) or
|
||||
(thumb_preference == nil and (thumb_info.height or 0) > thumb_height) then
|
||||
thumb = thumb_info.url
|
||||
thumb_height = thumb_info.height or 0
|
||||
thumb_preference = thumb_info.preference
|
||||
|
@ -877,7 +878,7 @@ local function check_version(ytdl_path)
|
|||
end
|
||||
end
|
||||
|
||||
function run_ytdl_hook(url)
|
||||
local function run_ytdl_hook(url)
|
||||
local start_time = os.clock()
|
||||
|
||||
-- strip ytdl://
|
||||
|
@ -949,7 +950,8 @@ 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 not path:lower():match("%.exe$") 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)
|
||||
|
@ -958,11 +960,13 @@ function run_ytdl_hook(url)
|
|||
result = exec(command)
|
||||
break
|
||||
else
|
||||
msg.verbose("No youtube-dl found with path " .. path .. exesuf .. " in config directories")
|
||||
msg.verbose("No youtube-dl found with path " .. path .. exesuf ..
|
||||
" in config directories")
|
||||
command[1] = path
|
||||
result = exec(command)
|
||||
if result.error_string == "init" then
|
||||
msg.verbose("youtube-dl with path " .. path .. " 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 .. " in PATH")
|
||||
ytdl.path = path
|
||||
|
@ -994,7 +998,7 @@ function run_ytdl_hook(url)
|
|||
msg.verbose("stderr:", result.stderr)
|
||||
|
||||
-- trim our stderr to avoid spurious newlines
|
||||
ytdl_err = result.stderr:gsub("^%s*(.-)%s*$", "%1")
|
||||
local ytdl_err = result.stderr:gsub("^%s*(.-)%s*$", "%1")
|
||||
msg.error(ytdl_err)
|
||||
local err = "youtube-dl failed: "
|
||||
if result.error_string and result.error_string == "init" then
|
||||
|
|
Loading…
Reference in New Issue