Skip to content

Commit

Permalink
ytdl: check exit code before completing json parse
Browse files Browse the repository at this point in the history
When youtube-dl fails, it exits with an error code and prints an error
message on stderr, writing nothing to stdout. This resulted in a yajl
"unexpected EOF" error, which is unhelpful to users.

Fixes MusicPlayerDaemon#22
  • Loading branch information
arcnmx committed Dec 20, 2020
1 parent df949c8 commit b9c4a4e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lib/ytdl/Invoke.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,6 @@ YtdlProcess::Complete()
throw MakeErrno("failed to close youtube-dl pipe");
}

handle.CompleteParse();

int res;
if (waitpid(pid, &res, 0) < 0) {
throw MakeErrno("failed to wait on youtube-dl process");
Expand All @@ -150,6 +148,8 @@ YtdlProcess::Complete()
if (res) {
throw FormatRuntimeError("youtube-dl exited with code %d", res);
}

handle.CompleteParse();
}

void
Expand Down

0 comments on commit b9c4a4e

Please sign in to comment.