From b15b3f6711b996b0e837f0881a31d97192efa778 Mon Sep 17 00:00:00 2001 From: "Avi Halachmi (:avih)" Date: Sat, 26 Feb 2022 12:09:45 +0200 Subject: ytdl_hook.lua: consider any subprocess status != 0 as error Previously only status<0 was considered as error, but status>0 is also an error (the process exit code). Change to status != 0. This likely makes little to no difference in practice, because if stdout is empty or can't be parsed as JSON then it's considered an error anyway, but still, this is more correct. Also, on error, add the complete subprocess result to the verbose log. --- player/lua/ytdl_hook.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'player') diff --git a/player/lua/ytdl_hook.lua b/player/lua/ytdl_hook.lua index 613f5a3286..26913763df 100644 --- a/player/lua/ytdl_hook.lua +++ b/player/lua/ytdl_hook.lua @@ -825,13 +825,18 @@ function run_ytdl_hook(url) local parse_err = nil - if (es < 0) or (json == "") then + if (es ~= 0) or (json == "") then json = nil elseif json then json, parse_err = utils.parse_json(json) end if (json == nil) then + msg.verbose("status:", es) + msg.verbose("reason:", result.error_string) + msg.verbose("stdout:", result.stdout) + msg.verbose("stderr:", result.stderr) + -- trim our stderr to avoid spurious newlines ytdl_err = result.stderr:gsub("^%s*(.-)%s*$", "%1") msg.error(ytdl_err) -- cgit v1.2.3