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 = 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);
29 playVideoOnDreambox($videoUrl, $dreamboxUrl);
32 function errorInput($msg)
34 if (!headers_sent()) {
35 header('HTTP/1.0 400 Bad Request');
36 header('Content-type: text/plain');
42 function errorOut($msg, $httpStatus = '500 Internal Server Error')
44 if (!headers_sent()) {
45 header('HTTP/1.0 ' . $httpStatus);
46 header('Content-type: text/plain');
49 syslog(LOG_ERR, 'playVideoOnDreamboxProxy: ' . $httpStatus . ': ' . $msg);