From 17dc7fd4454492e1ac580b403ecbff5989153a59 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Mon, 23 Nov 2015 23:37:31 +0100 Subject: [PATCH] nice message for common error --- www/play.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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); -- 2.30.2