Download Links for Youtube in Wordpress Single Post


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. function str_between($string, $start, $end){ $string = " ".$string;
  2. $ini = strpos($string,$start); if ($ini == 0) return ""; $ini +=
  3. strlen($start); $len = strpos($string,$end,$ini) - $ini; return
  4. substr($string,$ini,$len); }
  5. function get_youtube_download_link($url){
  6. if( $url !== "")
  7. {
  8. $youtube_link = $url;
  9. //$url = get_post_meta($post->ID, 'url', true);
  10. if ( file_get_contents($youtube_link) !== "")
  11. {
  12. $youtube_page = file_get_contents($youtube_link);
  13. $v_id = str_between($youtube_page, "&video_id=", "&");
  14. $t_id = str_between($youtube_page, "&t=", "&");
  15. $flv_link = "http://www.youtube.com/get_video?video_id=$v_id&t=$t_id";
  16. $hq_flv_link = "http://www.youtube.com/get_video?video_id=$v_id&t=$t_id&fmt=6";
  17. $mp4_link = "http://www.youtube.com/get_video?video_id=$v_id&t=$t_id&fmt=18";
  18. $threegp_link =
  19. "http://www.youtube.com/get_video?video_id=$v_id&t=$t_id&fmt=17";
  20. echo "\t\tDownload (right-click > save as):\n\t\t";
  21. echo "<a href=\"$flv_link\">FLV</a>\n\t\t";
  22. echo "<a href=\"$hq_flv_link\">HQ FLV (if available)</a>\n\t\t";
  23. echo "<a href=\"$mp4_link\">MP4</a>\n\t\t";
  24. echo "<a href=\"$threegp_link\">3GP</a><br><br>\n";
  25. }
  26. }
  27. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.