1 - get_video_infos - infos sur une video youtube
function file_curl_contents($url,$pretend=true){
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept-Charset: UTF-8'));
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,  FALSE);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_URL, $url);
        if (!ini_get("safe_mode") && !ini_get('open_basedir') ) {curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);}
        curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
        if ($pretend){curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:19.0) Gecko/20100101 Firefox/29.0');}
    
        curl_setopt($ch, CURLOPT_REFERER, '');
        $data = curl_exec($ch);
        $response_headers = curl_getinfo($ch);

        // Google seems to be sending ISO encoded page + htmlentities, why??
        if($response_headers['content_type'] == 'text/html; charset=ISO-8859-1') $data = html_entity_decode(iconv('ISO-8859-1', 'UTF-8//TRANSLIT', $data)); 
        
        # $data = curl_exec($ch);

        curl_close($ch);

        return $data;
    }


function get_video_infos($url=null){
	// returns an array with all the youtube video's informations (available qualities/urls/format...)
	if (!empty($url)){
		if ($contenu=file_curl_contents($url)){
			preg_match_all('#"url_encoded_fmt_stream_map": "(.*?)"#', $contenu, $resultats);
			preg_match_all('#<title>(.*?)</title>#', $contenu, $title);
			$c=0;
			$p=array('title'=>$title[1][0]);
			$params=explode('\u0026',$resultats[1][0]); 
			foreach ($params as $param){
				$temp=explode('=',$param);
				if (isset($p[$c][$temp[0]])){$c++;}
				$p[$c][$temp[0]]=urldecode($temp[1]);
			}
			return $p;
		}else{return false;}
	}else{return false;}

}


echo '<pre>';print_r(get_video_infos('http://www.youtube.com/watch?v=oHg5SJYRHA0'));