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 //for the firefox extension
12 header('Access-Control-Allow-Origin: *');
14 if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'GET') {
15 require __DIR__ . '/form.php';
19 set_error_handler('errorHandlerStore');
21 [$pageUrl, $dryRun] = getPageUrl();
22 $json = getYoutubeDlJson($pageUrl, $youtubedlPath);
23 $videoUrl = extractVideoUrlFromJson($json);
24 if (php_sapi_name() == 'cli') {
25 echo $videoUrl . "\n";
27 header('Video-URL: ' . $videoUrl);
30 playVideoOnDreambox($videoUrl, $dreamboxUrl);
34 function errorInput($msg)
36 if (!headers_sent()) {
37 header('HTTP/1.0 400 Bad Request');
38 header('Content-type: text/plain');
44 function errorOut($msg, $httpStatus = '500 Internal Server Error')
46 if (!headers_sent()) {
47 header('HTTP/1.0 ' . $httpStatus);
48 header('Content-type: text/plain');
51 syslog(LOG_ERR, 'playVideoOnDreamboxProxy: ' . $httpStatus . ': ' . $msg);