2 $youtubedlPath = '/home/cweiske/bin/youtube-dl';
4 if (!isset($_GET['url']) || $_GET['url'] == '') {
5 header('HTTP/1.0 400 Bad Request');
6 header('Content-Type: text/plain');
7 echo "'url' parameter missing\n";
11 $parsed = parse_url($url);
12 if ($parsed === false || !isset($parsed['scheme']) || !isset($parsed['host'])) {
13 header('HTTP/1.0 400 Bad Request');
14 header('Content-Type: text/plain');
20 $youtubedlPath . ' --dump-json ' . escapeshellarg($url),
25 if ($retval === 127) {
26 header('HTTP/1.0 500 Internal Server Error');
27 header('Content-Type: text/plain');
28 echo "youtube-dl not found\n";
30 } else if ($retval > 0) {
31 header('HTTP/1.0 500 Internal Server Error');
32 header('Content-Type: text/plain');
33 echo "Error fetching video data\n";
37 header('HTTP/1.0 200 OK');
38 header('Content-Type: application/json');
39 echo implode("\n", $output) . "\n";