$pageUrl = getPageUrl();
$videoUrl = extractVideoUrl($pageUrl, $youtubedlPath);
-header('Video-URL: ' . $videoUrl);
+if (php_sapi_name() == 'cli') {
+ echo $videoUrl . "\n";
+} else {
+ header('Video-URL: ' . $videoUrl);
+}
playVideoOnDreambox($videoUrl, $dreamboxHost);
function getPageUrl()
. ' --quiet'
. ' --dump-json'
. ' ' . escapeshellarg($pageUrl)
- . ' 2>&1';
+ . ' 2> /dev/null';
$lastLine = exec($cmd, $output, $exitCode);
if ($exitCode !== 0) {
$url = null;
foreach ($data->formats as $format) {
- //dreambox 7080hd does not play hls files
if (strpos($format->format, 'hls') !== false) {
+ //dreambox 7080hd does not play hls files
+ continue;
+ }
+ if ($format->protocol == 'http_dash_segments') {
+ //split up into multiple small files
continue;
}
$url = $format->url;
//use URL chosen by youtube-dl
$url = $data->url;
}
+
+ if ($url == '') {
+ errorOut(
+ 'No video URL found',
+ '406 No video URL found'
+ );
+ }
return $url;
}
header('HTTP/1.0 400 Bad Request');
header('Content-type: text/plain');
echo $msg . "\n";
- syslog(LOG_ERR, 'playVideoOnDreamboxProxy: ' . $httpStatus . ':' . $msg);
exit(1);
}