diff --git a/downloader.php b/downloader.php index dbcdd44..ff644ee 100644 --- a/downloader.php +++ b/downloader.php @@ -71,10 +71,17 @@ $hash = $hash[1]; } +// Scrape embed URL +$embedPage = get_web_page("http://embed.indavideo.hu/player/video/$hash"); + // Get video URL -$result = get_web_page(INDA_AMFPHP . $hash); -if ($result['http_code'] != 200) +$result = get_web_page(INDA_AMFPHP . $hash, ['headers' => [ + 'Referer' => 'https://assets.indavideo.hu' +]]); + +if ($result['http_code'] != 200) { error("Az amfphp nem elérhető"); +} $page = $result['content']; $page = json_decode($page); @@ -96,4 +103,4 @@ 'success' => true, 'video_url' => $url ])); -} \ No newline at end of file +} diff --git a/functions.php b/functions.php index faaaf28..617dae7 100644 --- a/functions.php +++ b/functions.php @@ -27,13 +27,12 @@ function error($msg, $hotlink = false) * @param string $url * @return array */ -function get_web_page($url) +function get_web_page($url, $requestOptions = []) { $user_agent = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1'; $cookie = tempnam("/tmp", "CURLCOOKIE"); $options = array( - CURLOPT_CUSTOMREQUEST => "GET", //set request type post or get CURLOPT_POST => false, //set to GET CURLOPT_USERAGENT => $user_agent, //set user agent @@ -51,6 +50,18 @@ function get_web_page($url) $ch = curl_init($url); curl_setopt_array($ch, $options); + + if (!empty($requestOptions)) { + if (!empty($requestOptions['headers'])) { + foreach ($requestOptions['headers'] as $headerKey => $headerValue) { + curl_setopt($ch, + CURLOPT_HTTPHEADER, + ["$headerKey: $headerValue"] + ); + } + } + } + $content = curl_exec($ch); $err = curl_errno($ch); $errmsg = curl_error($ch); @@ -60,6 +71,7 @@ function get_web_page($url) $header['errno'] = $err; $header['errmsg'] = $errmsg; $header['content'] = $content; + return $header; }