From b27fa518c9ba30cd1eddc5060b4f152eec6c38c8 Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Tue, 6 Feb 2018 19:20:56 +0100 Subject: [PATCH] feat: Add youtube-dl exit code to the exceptions --- classes/VideoDownload.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/classes/VideoDownload.php b/classes/VideoDownload.php index 79b89e4..15f76a3 100644 --- a/classes/VideoDownload.php +++ b/classes/VideoDownload.php @@ -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());