2 $youtubedlPath = '/usr/bin/youtube-dl';
3 $dreamboxUrl = 'http://dreambox';
5 require_once __DIR__ . '/functions.php';
6 $cfgFile = __DIR__ . '/../data/config.php';
7 if (file_exists($cfgFile)) {
11 if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'GET') {
12 require __DIR__ . '/form.php';
16 set_error_handler('errorHandlerStore');
18 $pageUrl = getPageUrl();
19 $json = getYoutubeDlJson($pageUrl, $youtubedlPath);
20 $videoUrl = extractVideoUrlFromJson($json);
21 if (php_sapi_name() == 'cli') {
22 echo $videoUrl . "\n";
24 header('Video-URL: ' . $videoUrl);
26 playVideoOnDreambox($videoUrl, $dreamboxUrl);
29 function errorInput($msg)
31 if (!headers_sent()) {
32 header('HTTP/1.0 400 Bad Request');
33 header('Content-type: text/plain');
39 function errorOut($msg, $httpStatus = '500 Internal Server Error')
41 if (!headers_sent()) {
42 header('HTTP/1.0 ' . $httpStatus);
43 header('Content-type: text/plain');
46 syslog(LOG_ERR, 'playVideoOnDreamboxProxy: ' . $httpStatus . ': ' . $msg);