Skip to content
This repository has been archived by the owner on Aug 12, 2023. It is now read-only.

Commit

Permalink
Append referer to AMF request)
Browse files Browse the repository at this point in the history
  • Loading branch information
nxu committed Jan 3, 2017
1 parent 37e51ec commit ee6e7aa
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
13 changes: 10 additions & 3 deletions downloader.php
Expand Up @@ -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);
Expand All @@ -96,4 +103,4 @@
'success' => true,
'video_url' => $url
]));
}
}
16 changes: 14 additions & 2 deletions functions.php
Expand Up @@ -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
Expand All @@ -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);
Expand All @@ -60,6 +71,7 @@ function get_web_page($url)
$header['errno'] = $err;
$header['errmsg'] = $errmsg;
$header['content'] = $content;

return $header;
}

Expand Down

0 comments on commit ee6e7aa

Please sign in to comment.