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.
This commit is contained in:
Avi Halachmi (:avih) 2022-02-26 12:09:45 +02:00
parent 11f0947d46
commit b15b3f6711
1 changed files with 6 additions and 1 deletions

View File

@ -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)