Youtube downloader is working!
For more than a month my youtube downloader script was not working due to youtube changed their layout. Today I’ve rewritten the script and simplified the functionality. Now mobi.web.id is running again and ready to help everyone download videos from Youtube.
Previous script consist of four functions and I’ve shortened into two functions. Please hit the read button to see the full working script.
Here’s the shorten code for youtube downloader:
function get_http_header($url){
$uh = curl_init();
curl_setopt($uh, CURLOPT_URL, $url);
curl_setopt($uh, CURLOPT_HEADER, 1);
curl_setopt($uh, CURLOPT_RETURNTRANSFER, 1);
$res = curl_exec($uh);
curl_close($uh);
return $res;
}
function show_url($http_header){
$arai = explode(”\n”,$http_header);
foreach($arai as $ini){
if(eregi(”location”,$ini)) $url = $ini;
}
list($sampah,$hasil) = explode(”Location:”,$url);
return str_replace(”\n”,”",trim($hasil));
}
function download_youtube($url){
if(ereg(’&',$url)){
if (eregi(”watch\?v=(.*)&”, $url, $out)) {
$video_id = $out[1];
}
}
else{
list($none,$video_id) = explode(’watch?v=’,$url);
}
$secret_link = substr(show_url(get_http_header(’http://youtube.com/v/’.trim($video_id))),11);
$video_url = show_url(get_http_header(’http://youtube.com/get_video?’.$secret_link));
list($dl_url,$sign) = explode(”&signature”,$video_url);
return $dl_url;
}
// EXAMPLE:
echo download_youtube(’http://www.youtube.com/watch?v=5uy7SAidyTM’);
?>
Have phun, may the source be with you! ^_^
March 3rd, 2008 at 10:29 pm
thanks info nya kang..geleng2 saya ksini tiba2 theme nya jadi ciamik eram…
March 4th, 2008 at 11:28 am
sip… langsung ta coba
March 11th, 2008 at 8:19 pm
wah, sudah main adsenses rupanya. makan-makaaaaan …
March 25th, 2008 at 10:06 am
ndal dirimu tau komen buat softlens kah?
April 4th, 2008 at 8:42 am
Youtube changed links. How i could repair it??
April 5th, 2008 at 3:16 pm
its amazing, how did you find t his out
April 7th, 2008 at 6:52 am
not working
June 6th, 2008 at 8:02 pm
not working !!!!!!!!!!!! stupid script
June 17th, 2008 at 5:14 pm
Thaaks for the functions
July 4th, 2008 at 5:49 pm
Very nice script.i use it with my image hosting website.thanks a lot.
July 14th, 2008 at 3:31 am
thank you for such a great topic. I have learned a lot by reading on this website today.
July 19th, 2008 at 1:11 pm
For some reason I can’t get the code to work. Somthing is missing.