Ответа не дождался - сам написал :)
Скорость примерно 500кб/с, ограничения на скачку зависит только от вашего хостинга.
$user_agent = 'Mozilla/5.0 (Windows; U; Windows NT 6.0; ru; rv:1.9.2.13) ' . 'Gecko/20101203 Firefox/3.6.13 ( .NET CLR 3.5.30729)';
function curl_gets_exec($ch, $redirects = 0, $curlopt_returntransfer = true, $curlopt_maxredirs = 10, $curlopt_header = false) {
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$data = curl_exec($ch);
$header=substr($data,0,curl_getinfo($ch,CURLINFO_HEADER_SIZE));
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$exceeded_max_redirects = $curlopt_maxredirs > $redirects;
$exist_more_redirects = false;
if ($http_code == 301 || $http_code == 302) {
if ($exceeded_max_redirects) {
list($header) = explode("\r\n\r\n", $data, 2);
$matches = array();
preg_match('/(Location:|URI:)(.*?)\n/', $header, $matches);
$url = trim(array_pop($matches));
$url_parsed = parse_url($url);
if (isset($url_parsed)) {
curl_setopt($ch, CURLOPT_URL, $url);
$redirects++;
return curl_gets_exec($ch, $redirects, $curlopt_returntransfer, $curlopt_maxredirs, $curlopt_header);
}
}
else {
$exist_more_redirects = true;
}
}
if ($data !== false) {
if (!$curlopt_header)
list(,$data) = explode("\r\n\r\n", $data, 2);
if ($exist_more_redirects) return false;
if ($curlopt_returntransfer) {
return $data;
}
else {
echo $data;
if (curl_errno($ch) === 0) return true;
else return false;
}
}
else {
return false;
}
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
$hd=$_GET[hd];
$name=$_GET[name];
$link=$_GET[link];
curl_setopt($ch, CURLOPT_URL, $link);
$answer = curl_gets_exec($ch);
include './engine/simple_html_dom.php';
$html = new simple_html_dom();
$html->load($answer);
$div_video=$html->find('object',0);
if($div_video->outertext=="")die($link);
if(preg_match("/url".$hd."=(.*?)&/", $div_video->outertext, $output)) {
$link = $output[1];
}
$html->clear();
if($link==""){die("Ошибка, видео в таком формате не существует.");}
function file_force_download($file, $name) {
if (ob_get_level()) {
ob_end_clean();
}
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=' . $name . '.mp4');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
$tFile = fopen($file,'r');
while (!feof($tFile))
{
echo( fgets($tFile));
}
fclose($tFile);
exit;
}
file_force_download($link,$name);