/*
YouTube Parser
*/
set_time_limit(0);
/* $login_url = "http://www.youtube.com/login";
$tmp = explode('/', $url);
$tmp = $tmp[count($tmp) - 1];
$login_url = "http://www.youtube.com/login?next_url=/".urlencode($tmp);
// $post_data = "current_form=loginForm&next_url=".urlencode($tmp)."&username=pfslapfiles&password=automated&action_login=Log%20In";
$post_data = "current_form=loginForm&next_url=".$tmp."&username=pfslapfiles&password=automated&action_login=Log%20In";
echo($tmp);
echo("
and: " . $post_data);
die();
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $login_url);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_COOKIEJAR, "./cookie.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, "./cookie.txt");
$html = curl_exec($ch);
curl_setopt($ch, CURLOPT_URL, "http://www.youtube.com/verify_age?next_url=".urlencode($tmp));
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, "action_confirm=Confirm&next_url=".urlencode($tmp));
curl_setopt($ch, CURLOPT_COOKIEJAR, "./cookie.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, "./cookie.txt");
$html = curl_exec($ch);
curl_close($ch); */
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_COOKIEJAR, "./cookie.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, "./cookie.txt");
$html = curl_exec($ch);
if(preg_match('/(video_id=.+?)&.+?(&t=.+?)&f/', $html, $matches))
{
$flv = 'http://www.youtube.com/get_video?'.$matches[1].$matches[2];
// get the title
if(preg_match('/