If you want to get the FLV file of any youtube video url using php code, here is the solution.

If you are a PHP Programmer and if you are working with any video website, and if you need to grab videos (FLV files) from youtube and to put it yourown site (not object embedding) , Download the Full Source Code given at the end of this article (ZIP)

I used this php code for the Youtube video download tool http://www.googleneedle.com

Here function getPatternFromUrl is nothing but, get the exact pattern of a particular video from any youtube video url format.

In the above case , it returns pzmP4UvZRa4

The function is below

function getPatternFromUrl($url) { $url = $url.'&'; $pattern = '/v=(.+?)&+/'; preg_match($pattern, $url, $matches); return ($matches[1]); }

GetFlvFromYoutube is the main function here, which download the flv file from youtube pattern and saves to your local machine.
The function is below:

function GrabFlvFromYoutube( $pattern ) { requireonce ("phptube.php"); $tube = new PHPTube (); $flvhttppath = $tube->download($pattern) ; echo $flvhttppath; settimelimit(0); $data = filegetcontents($flvhttppath); $newflvpath = dirname(FILE).'/flvs/'.$pattern.'.flv' ; fileputcontents($newflvpath, $data); return $newflv_path ; }

Hey, the old script I wrote is not working as youtube constantly changing their way they serve the contents.

I updated googleneedle website with code from here: http://1chris.com/post/39/using-php-to-download-youtube-flvs/

It works now, thank you Chris