[PHP] Download YouTube FLV or MP4 or HD this is Working as of 28-11-2011 and has been updated

0 replies
[PHP] Download YouTube FLV or MP4 or HD this is Working as of 28-11-2011 and has been updated

Credits to JmZ for posting a youtube flv guide few days back somewhere

Code:
<?php
error_reporting(0);
/*********************************************************
*                                                        *
* Author: Vick@PHPCanyon.net                             *
* Site  : www.PHPCanyon.net                              *
* Date  : 28/11/2011                                     *
* Notes : This doesn't just download MP4, It Downloads   *
*         either mp4, flv, which ever is better.         *
*                                                        *
* How to use?                                            *
* YouTubeToMP4("videoidhere");                           *
* ^ Outputs Direct Link to Download.                     *
*                                                        *
*                   BE AWARE YOUTUBE MIGHT               *
*                  BAN/BLOCK YOUR IP IF YOU              *
*                MISS-USE/MASS USE THIS SCRIPT           *
*                THIS SCRIPT COMES "AS-IS" AND           *
*                YOU ARE RESPONSIBLE FOR YOUR            *
*                OWN ACTIONS AND HOW-EVER YOU            *
*                USE THIS SCRIPT, IF YOU DISAGREE        *
*                THEN CLOSE THIS TEXT EDITOR RIGHT       *
*                NOW AND DELETE THIS SCRIPT !            *
*                                                        *      
* FAQ                                                    *      
* 1. I can Only see "&title="?                           *      
*    -> Your Banned GG.                                  * 
*                                                        *      
**********************************************************/
function YouTubeToMP4($videoid)
{
  // Pass VideoID into $url to create Video URL to Watch
  $url = "http://www.youtube.com/watch?v=$videoid";
 
  // Get Page Contents and put in Variable
  $pageSource = file_get_contents($url);
 
  /* Using Regex we need to grab 2 required params to
  generate a download link */
 
  // Get Snippet
  $snippet = '/img.src = "(.+?)";/';
  preg_match($snippet, $pageSource, $match_snippet);
  $rawSource = urldecode($match_snippet[1]);
 
   // Get TITLE
  $title_snippet = '/meta name="title" content="(.+?)">/';
  preg_match($title_snippet, $pageSource, $match_title_snippet);
  $title = $match_title_snippet[1];
 
  // Remove spaces and add '%20', theres better ways but
  // this felt easier at the time.
  $removeSpaces = " ";
  $add = "%20";
  $newTitle = str_replace($removeSpaces, $add, $title);
 
  // Remove '\'
  $removeThis = '\\';
  $result = str_replace($removeThis, "", $rawSource);
  $newURL =  $result . "&title=$newTitle";
 
  // Remove 'u0026' and replace with '&'
  $andRemoveThis = 'u0026';
  $result_ = str_replace($andRemoveThis, "&", $newURL);
 
  // Replace link with watch link
  $Laps = "generate_204?";
  $rounds = "videoplayback?";
  $circuit = str_replace($Laps, $rounds, $result_);
  echo $circuit;
}
// Call this function with "videoidhere"
YouTubeToMP4("ooZwmeUfuX");
?>
Original Post @ PHPCanyon.net
#download #flv #mp4 #php #updated #working #youtube

Trending Topics