nice message for common error
authorChristian Weiske <cweiske@cweiske.de>
Mon, 23 Nov 2015 22:37:31 +0000 (23:37 +0100)
committerChristian Weiske <cweiske@cweiske.de>
Mon, 23 Nov 2015 22:37:31 +0000 (23:37 +0100)
www/play.php

index 353103517306c40b632a329b7e196c567d7e26e3..0133f5b1c066f5f74b7fcef9cebc0b774e06b013 100644 (file)
@@ -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);