www.youtube.com

< ?php

if(!empty($_GET[‚url’])) {
$url = „https://www.youtube.com/watch?v=”.$_GET[‚url’];

$ch1= curl_init();
curl_setopt ($ch1, CURLOPT_URL, „$url” );
curl_setopt($ch1, CURLOPT_HEADER, 0);
curl_setopt($ch1,CURLOPT_VERBOSE,1);
//curl_setopt($ch1, CURLOPT_USERAGENT, ‚Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_2_1 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C148 Safari/6533.18.5′);
curl_setopt ($ch1, CURLOPT_REFERER,’http://www.google.com’); //just a fake referer
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch1,CURLOPT_POST,0);
curl_setopt($ch1, CURLOPT_FOLLOWLOCATION, 20);

$htmlContent= curl_exec($ch1);;
$source = urldecode($htmlContent);

$downloadURL = explode(‚url_encoded_fmt_stream_map’, $source);
$downloadURL = substr($downloadURL[1], 0, 15600);

$downloadURL = explode("url=", $downloadURL);

$mp4link = str_split($downloadURL[1]);

$newmp4link = array();

for($i=0;$i<count($mp4link);$i++) {
array_push($newmp4link, $mp4link[$i]);
if($mp4link[$i] == '\\' || $mp4link[$i] == ',') {
    break;
}
}

$newmp4link = join("", $newmp4link);

$newmp4link = str_replace("\\","", $newmp4link);
$newmp4link = str_replace(",","", $newmp4link);
$newmp4link = str_replace(";","", $newmp4link);

$ext = "mp4";

function generateRandomString($length) {
$characters = ‚0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ’;
$randomString = ”;
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, strlen($characters) – 1)];
}
return $randomString;
}
$rand = generateRandomString(100);
$target = „tmp/$rand.mp4”;
copy($newmp4link, $target);
echo „$newmp4link”;
header(„Location: tmp/$rand.mp4”);

?>