We Recommend

Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems
Wicked Cool PHP contains a wide variety of scripts to process credit cards, check the validity of email addresses, template HTML, and serve dynamic images and text.


Posted By

jacksont123 on 07/01/08


Tagged

link generator video download YouTube jacksont123


Versions (?)


Who likes this?

3 people have marked this snippet as a favorite

jacksont123
SpinZ
navjotjsingh


Youtube Download Link Generator


Published in: PHP 


URL: http://youtube.com

YouTube Video Download Link Generator free for all to use, successfulness can't be guaranteed

  1. //YouTube Video Download Link Generator -- jacksont123 (2008)
  2. function str_between($string, $start, $end){ $string = " ".$string; $ini = strpos($string,$start); if ($ini == 0) return ""; $ini += strlen($start); $len = strpos($string,$end,$ini) - $ini; return substr($string,$ini,$len); }
  3. function get_youtube_download_link(){
  4. $youtube_link = $_GET['youtube'];
  5. $youtube_page = file_get_contents($youtube_link);
  6. $v_id = str_between($youtube_page, "&video_id=", "&");
  7. $t_id = str_between($youtube_page, "&t=", "&");
  8. $flv_link = "http://www.youtube.com/get_video?video_id=$v_id&t=$t_id";
  9. $hq_flv_link = "http://www.youtube.com/get_video?video_id=$v_id&t=$t_id&fmt=6";
  10. $mp4_link = "http://www.youtube.com/get_video?video_id=$v_id&t=$t_id&fmt=18";
  11. $threegp_link = "http://www.youtube.com/get_video?video_id=$v_id&t=$t_id&fmt=17";
  12. echo "\t\tDownload (right-click > save as):\n\t\t";
  13. echo "<a href=\"$flv_link\">FLV</a>\n\t\t";
  14. echo "<a href=\"$hq_flv_link\">HQ FLV (if available)</a>\n\t\t";
  15. echo "<a href=\"$mp4_link\">MP4</a>\n\t\t";
  16. echo "<a href=\"$threegp_link\">3GP</a><br><br>\n";
  17. }

Report this snippet 

Comments

RSS Icon Subscribe to comments
Posted By: navjotjsingh on November 7, 2008

Excellent and so easy to implement! Works wonderfully!

You need to login to post a comment.