- Code: Tout sélectionner
//
// Retourne l'url d'une video Dailymotion à partir de son ID (ex: x6xmv0)
//
// (c) NETLEIX.FR 2008
//
function GetDailymotionFLV($Id)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL,"http://www.dailymotion.com/swf/$Id");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HEADER, 0);
$Response = curl_exec($curl);
$Buffer = substr($Response, 8);
$SWF = gzuncompress($Buffer);
preg_match_all("|(\/get\/.*[^@])@|U", $SWF, $Out, PREG_PATTERN_ORDER);
$VideoList = array();
foreach($Out[1] as $VideoUrl)
{
$Width = ereg_replace("/get/[^/]*/([0-9]*)[^/]*/.*", "\\1", $VideoUrl);
$VideoList[$Width] = $VideoUrl;
}
ksort($VideoList);
$VideoUrl = array_pop($VideoList);
curl_setopt($curl, CURLOPT_URL,"http://www.dailymotion.com" . $VideoUrl);
curl_setopt($curl, CURLOPT_HEADER, 1);
$Response = curl_exec($curl);
$LocationUrl = ereg_replace(".*\nLocation: ([^\r\n]*).*", "\\1", urldecode($Response));
curl_close($curl);
return $LocationUrl;
}
Youtube :
- Code: Tout sélectionner
function get_youtube($id_video) {
$page = file_get_contents("http://fr.youtube.com/watch?v=".$id_video);
eregi('"t": "(.*)", "hl":', $page, $url);
$headers = get_headers('http://www.youtube.com/get_video?video_id='.$id_video.'&t='.$url[1], 1);
return $headers['Location'];
}
Si quelqu'un veut publier un script qui marche sur d'autres tubes (youtube, etc...) c'est ici !
