feat: Add youtube-dl exit code to the exceptions

This commit is contained in:
Pierre Rudloff 2018-02-06 19:20:56 +01:00
parent 5a527373bd
commit b27fa518c9

View file

@ -110,12 +110,13 @@ class VideoDownload
$process->run();
if (!$process->isSuccessful()) {
$errorOutput = trim($process->getErrorOutput());
$exitCode = $process->getExitCode();
if ($errorOutput == 'ERROR: This video is protected by a password, use the --video-password option') {
throw new PasswordException($errorOutput);
throw new PasswordException($errorOutput, $exitCode);
} elseif (substr($errorOutput, 0, 21) == 'ERROR: Wrong password') {
throw new Exception(_('Wrong password'));
throw new Exception(_('Wrong password'), $exitCode);
} else {
throw new Exception($errorOutput);
throw new Exception($errorOutput, $exitCode);
}
} else {
return trim($process->getOutput());