From: Christian Weiske Date: Wed, 6 Mar 2019 20:20:40 +0000 (+0100) Subject: Better error reporting for errors when sending video to dreambox X-Git-Tag: v1.1.0~2 X-Git-Url: https://git.cweiske.de/playVideoOnDreamboxProxy.git/commitdiff_plain/53547a00a04ba956104748231cdc4d140355544d?hp=d7c339117f8bd06942c95460050d85185ef52676;ds=sidebyside Better error reporting for errors when sending video to dreambox --- diff --git a/www/functions.php b/www/functions.php index ffd6667..b094e36 100644 --- a/www/functions.php +++ b/www/functions.php @@ -114,6 +114,13 @@ function playVideoOnDreambox($videoUrl, $dreamboxUrl) ini_set('track_errors', 1); $xml = @file_get_contents($dreamboxUrl . '/web/session'); if ($xml === false) { + if (!isset($http_response_header)) { + errorOut( + 'Error fetching dreambox web interface token: ' + . $GLOBALS['lastError'] + ); + } + list($http, $code, $message) = explode( ' ', $http_response_header[0], 3 ); @@ -161,4 +168,11 @@ function playVideoOnDreambox($videoUrl, $dreamboxUrl) ); } } + +function errorHandlerStore($number, $message, $file, $line) +{ + $GLOBALS['lastError'] = $message; + return false; +} +$GLOBALS['lastError'] = null; ?> diff --git a/www/play.php b/www/play.php index 983cd7f..8109951 100644 --- a/www/play.php +++ b/www/play.php @@ -8,6 +8,8 @@ if (file_exists($cfgFile)) { include $cfgFile; } +set_error_handler('errorHandlerStore'); + $pageUrl = getPageUrl(); $json = getYoutubeDlJson($pageUrl, $youtubedlPath); $videoUrl = extractVideoUrlFromJson($json);