Youtube downloader is working!

March 3, 2008 | PHP

Mobi.web.idFor 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:

< ?php
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! ^_^

19 comments

This post has 19 comments, great!

  1. cempluk 03/03/2008 at 22:29

    thanks info nya kang..geleng2 saya ksini tiba2 theme nya jadi ciamik eram…

  2. mikow 04/03/2008 at 11:28

    sip… langsung ta coba

  3. ndoro kakung 11/03/2008 at 20:19

    wah, sudah main adsenses rupanya. makan-makaaaaan … :D

  4. omith 25/03/2008 at 10:06

    ndal dirimu tau komen buat softlens kah?

  5. Dave 04/04/2008 at 08:42

    Youtube changed links. How i could repair it??

  6. hello 05/04/2008 at 15:16

    its amazing, how did you find t his out :D

  7. getpr 07/04/2008 at 06:52

    not working

  8. Kiko 06/06/2008 at 20:02

    not working !!!!!!!!!!!! stupid script

  9. Alen Cribson 17/06/2008 at 17:14

    Thaaks for the functions

  10. Photoking 04/07/2008 at 17:49

    Very nice script.i use it with my image hosting website.thanks a lot.

  11. youtube traffic 14/07/2008 at 03:31

    thank you for such a great topic. I have learned a lot by reading on this website today.

  12. Hanna 19/07/2008 at 13:11

    For some reason I can’t get the code to work. Somthing is missing.

  13. johny 12/10/2008 at 11:29

    Domain mobi.web.id nya expired nih. Udah diperpanjang belum ?
    Thanks.

  14. operaTor 13/11/2008 at 22:55

    Script is updated, please take a look at http://sandalian.com/php/current-working-php-youtube-downloader.html

  15. fitimi 23/09/2009 at 02:27

    fucky england Im from albani for everrrrrrrr

  16. kamau94 03/01/2010 at 19:06

    Hey , i found very easy youtube php downloader script you (inc. Hd Download , flv ,mp4 )

    http://www.animestreamers.com/portfolio/youtube_download/

    Happy Newyear by the way !
    Char7983-(Autoit3)

  17. john 11/03/2010 at 05:28

    eregi = R.I.P !!!

    Do not use eregi anymore

  18. Andy Gee 13/09/2010 at 23:20

    A new one is here http://www.dumaguetewebdesign.com/youtube.php
    It’s not pretty but it’s working as of 13/9/2010
    It also downloads entire playlists :)

  19. monclers 02/09/2011 at 17:05

    I intended to post you that very small remark to be able to say thanks a lot yet again on your fantastic tricks you have featured on this website. This is so incredibly generous of you to provide publicly all that most people could possibly have offered for sale for an electronic book in order to make some cash for themselves, precisely considering that you might well have tried it in the event you considered necessary. Those solutions also worked to be a easy way to realize that other individuals have the same desire like my very own to realize many more related to this matter. I am sure there are a lot more fun opportunities in the future for individuals who check out your site.

 

Leave a comment

Allowed tags are: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>


 



Switch to our mobile site