Hi, Im working in a video downloader. I want to put the code of the video in an input an then the video starts downloading.
The problem is that Youtube ask for a code to start the download.
I've done a PHP script that get that code but I dont know how to use the code Ive get on AMS.
The script is:
I need this part:"&t=".getHeaders($videoIds));"
Thanks and apologize for my bad english :S
The problem is that Youtube ask for a code to start the download.
I've done a PHP script that get that code but I dont know how to use the code Ive get on AMS.
The script is:
PHP Code:
<?php
function getHeaders($varurl) {
$host = "www.youtube.com";
$url = "/v/".$varurl;
$session = "";
$fp = fsockopen ($host, 80, $errno, $errstr, 45);
if ($fp) {
fputs ($fp, "GET $url HTTP/1.0\r\n\r\n");
while (!feof($fp)) {
$char = fgetc($fp);
if($char === "\n") {
if (ord($header) === 13) {
return($session);
} else {
$arrValue = split(": ", trim($header));
if ($arrValue[0] == "Location") {
parse_str($arrValue[1], $getvars);
$session = $getvars['t'];
}
}
unset($header);
} else {
$header = $header.$char;
}
}
fclose ($fp);
}
}
if ($_GET['v'] != "") {
$videoIds = $_GET['v'];
$videoUrl = "http://www.youtube.com/get_video.php";
header("Location: ".$videoUrl."?video_id=".$videoIds."&t=".getHeaders($videoIds));
exit();
}
?>
Thanks and apologize for my bad english :S