1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
| <?php
include '../config/config.php';
$req = mysql_query("SELECT link FROM tube");
if (mysql_num_rows($req) > 1){
while($data = mysql_fetch_assoc($req))
{
/*echo $data['link'];
echo '<br>';*/
function getVideoInfo($url){
$type = "";
$id = -1;
$titre = "no title";
$description = "no description";
$code = "no code";
$img = "no image";
//D?rmination du "type" de vid?:
if(eregi("youtube",$url)) $type="youtube";
else if(eregi("dailymotion",$url)) $type="dailymotion";
else if(eregi("google",$url)) $type="google";
else if(eregi("vimeo",$url)) $type="vimeo";
else return false;
//D?rmination de l'"ID" de la vid?:
if($type=="youtube"){
$debut_id = explode("v=",$url,2);
$id_et_fin_url = explode("&",$debut_id[1],2);
$id = $id_et_fin_url[0];
}
else if($type=="dailymotion"){
$debut_id = explode("/video/",$url,2);
$id_et_fin_url = explode("_",$debut_id[1],2);
$id = $id_et_fin_url[0];
}
else if($type=="google"){
$debut_id = explode("docid=",$url,2);
$id_et_fin_url = explode("&",$debut_id[1],2);
$id = $id_et_fin_url[0];
}
else if($type=="vimeo"){
$l_id= eregi("([0-9]+)$",$url,$lid);
$id = $lid[0];
}
//Analyse et stockage des informations de la vid?
if($type=="youtube"){
$xml = @file_get_contents("http://gdata.youtube.com/feeds/api/videos/".
$id);
//titre
preg_match('#<title(.*?)>(.*)<\/title>#is',$xml,$resultTitre);
$titre = $resultTitre[count($resultTitre)-1];
//description
preg_match('#<content(.*?)>(.*)<\/content>#is',$xml,$resultDescription);
$description = $resultDescription[count($result)-1];
//Image
$img = "http://img.youtube.com/vi/".$id."/1.jpg";
//Code HTML
$code =
'<object width="425" height="355"><param name="movie"' .
' value="http://www.youtube.com/v/'.$id.
'&hl=fr"></param><param name="wmode" value="transparent"></param><embed' .
' src="http://www.youtube.com/v/'.$id.
'&hl=fr" type="application/x-shockwave-flash" wmode="transparent" width="425"' .
' height="355"></embed></object>';
}
else if ($type=="dailymotion"){
$tags = get_meta_tags("http://www.dailymotion.com/video/".$id);
//titre
$titre = htmlspecialchars(trim(str_replace("Dailymotion -","",$tags[
"title"])));
//description
$description = $tags["description"];
//image
$img = "http://www.dailymotion.com/thumbnail/160x120/video/".$id;
// code HTML
$code =
'<div><object width="420" height="357"><param name="movie"' .
' value="http://www.dailymotion.com/swf/'.$id.
'&v3=1&related=1"></param><param name="allowFullScreen"' .
' value="true"></param><param name="allowScriptAccess" value="always"></param>' .
'<embed src="http://www.dailymotion.com/swf/'.$id.
'&v3=1&related=1" type="application/x-shockwave-flash" width="420"' .
' height="357" allowFullScreen="true" allowScriptAccess="always"></embed></obj' .
'ect></div>';
}
else if ($type=="google"){
$xml_string = @file_get_contents(
"http://video.google.com/videofeed?docid=".$id);
//titre
$xml_title_debut = explode("<title>",$xml_string,2);
$xml_title_fin = explode("</title>",$xml_title_debut[1],2);
$titre = $xml_title_fin[0];
//description
$xml_description_debut = explode("<description>",$xml_string,2);
$xml_description_fin = explode("</description>",$xml_description_debut[1
],2);
$description = $xml_description_fin[0];
//image
$xml_image_debut = explode('<img src="',$xml_string,2);
$xml_image_fin = explode('" width="',$xml_image_debut[1],2);
$img = $xml_image_fin[0];
//code HTML
$code =
'<embed style="width:400px; height:326px;" id="VideoPlayback"' .
' type="application/x-shockwave-flash" src="http://video.google.com/googleplay' .
'er.swf?docId='.$id.'&hl=fr" flashvars=""> </embed>';
}
else if ($type=="vimeo"){
$xml_string = @file_get_contents("http://vimeo.com/api/clip/".$id.".xml"
);
//titre
$xml_title_debut = explode("<title>",$xml_string,2);
$xml_title_fin = explode("</title>",$xml_title_debut[1],2);
$titre = $xml_title_fin[0];
//description
$xml_description_debut = explode("<caption>",$xml_string,2);
$xml_description_fin = explode("</caption>",$xml_description_debut[1],2)
;
$description = $xml_description_fin[0];
//image
$xml_image_debut = explode("<thumbnail_large>",$xml_string,2);
$xml_image_fin = explode("</thumbnail_large>",$xml_image_debut[1],2);
$img = $xml_image_fin[0];
//code HTML
$xml_code = @file_get_contents(
"http://vimeo.com/api/oembed.xml?url=http%3A//vimeo.com/".$id);
$xml_code_debut = explode("<html>",$xml_code,2);
$xml_code_fin = explode("</html>",$xml_code_debut[1],2);
$code = str_replace("<![CDATA[","",str_replace("]]>","",$xml_code_fin[0]
));
}
return array("id"=>$id,"type"=>$type,"titre"=>$titre,"description"=>
$description,"img"=>$img,"code"=>$code);
}
$urlVideo = $data['link'];
$infosVideo = getVideoInfo($urlVideo);
echo 'Image de la vid?: <a href=page.php?id='.$infosVideo["id"].'><img alt="Image de la video" src="'.$infosVideo["img"].'" border=0/> </a><br />';
}
}else{
echo 'Error les ligne plus d\'un 1';
}
/*for ($j = 0; $j<mysql_num_rows($req); $j++) {
}
for ($k = 0; $k<mysql_num_fields($req); $k++) {
echo "<td align=center>".mysql_result($req,$j,$k)."</td>";
}
*/
?> |
Partager