From: Christian Weiske Date: Mon, 23 Nov 2015 22:37:31 +0000 (+0100) Subject: nice message for common error X-Git-Tag: v0.1.0~1 X-Git-Url: https://git.cweiske.de/playVideoOnDreamboxProxy.git/commitdiff_plain/17dc7fd4454492e1ac580b403ecbff5989153a59?ds=sidebyside nice message for common error --- diff --git a/www/play.php b/www/play.php index 3531035..0133f5b 100644 --- a/www/play.php +++ b/www/play.php @@ -41,7 +41,11 @@ function extractVideoUrl($pageUrl, $youtubedlPath) $lastLine = exec($cmd, $output, $exitCode); if ($exitCode !== 0) { - errorOut('youtube-dl error: ' . $lastLine); + if (strpos($lastLine, 'Unsupported URL') !== false) { + errorOut('Unsupported URL', '400 Unsupported URL (No video found)'); + } else { + errorOut('youtube-dl error: ' . $lastLine); + } } return $lastLine; } @@ -91,9 +95,9 @@ function errorInput($msg) exit(1); } -function errorOut($msg) +function errorOut($msg, $httpStatus = '500 Internal Server Error') { - header('HTTP/1.0 500 Internal Server Error'); + header('HTTP/1.0 ' . $httpStatus); header('Content-type: text/plain'); echo $msg . "\n"; exit(2);