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
| <?
class Youtube
{
var $dom, $idvideo, $title, $video;
function videoTitle()
{
return $this->title;
}
function pagination()
{
return true;
}
function tag($tag, $page = 1)
{
if ($page <= 0) $page = 1;
$start = ($page-1)*10 + 1;
$tag = str_replace(' ', '+', $tag);
$feed = ('http://gdata.youtube.com/feeds/api/videos?vq='.$tag.'&start-index='.$start.'&max-results=10&orderby=updated&alt=rss');
$this->dom = getFeed($feed);
}
function video($id)
{
$this->idvideo = $id;
$feed = ("http://gdata.youtube.com/feeds/api/videos/".$id);
$this->dom = getFeed($feed);
$this->video = $this->dom->getElementsByTagName('entry')->item(0) // ligne 32;
$this->title = $this->video->getElementsByTagName('title')->item(0)->textContent;
}
function player()
{
?>
<object width="425" height="355">
<param name="movie" value="http://www.youtube.com/v/<?=$this->idvideo?>" />
<param name="wmode" value="transparent" />
<embed src="http://www.youtube.com/v/<?=$this->idvideo?>" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed>
</object>
<?
}
function view($tag)
{
$videos = $this->dom->getElementsByTagName('item');
foreach ($videos as $video)
{
$id = $video->getElementsByTagName('guid')->item(0)->textContent;
$id = explode('/', $id);
$id = $id[6];
echo '<div class="video">';
$title = $video->getElementsByTagName("title")->item(0)->textContent;
echo '<p><a href="'.BASE_URL.'/0/video/'.$tag.'/'.$id.'.html">'.$title.'</a></p>';
$fotos = $video->getElementsByTagNameNS("http://search.yahoo.com/mrss/", "thumbnail");
$tiempo = $video->getElementsByTagNameNS("http://gdata.youtube.com/schemas/2007", "duration");
$tiempo = $tiempo->item(0)->getAttribute("seconds");
$i = 0;
echo '<div class="img">';
foreach ($fotos as $foto)
{
$url = $foto->getAttribute("url");
echo '<a href="'.BASE_URL.'/0/video/'.$tag.'/'.$id.'.html"><img src="'.$url.'" alt="'.$title.'"/></a>';
$i++;
if ($i > 2) break;
}
echo '</div>';
echo '<p class="links"><a href="'.BASE_URL.'/0/video/'.$tag.'/'.$id.'.html">'._VIEW.'</a> '._DURATION.': '.minutes($tiempo).'</p>';
echo '<p>'.cut($video->getElementsByTagName("description")->item(0)->textContent).'</p>';
$tags = $video->getElementsByTagName("category");
echo '<div class="tags">'; echo 'tags: ';
foreach ($tags as $palabra)
{
if (strpos($palabra->textContent, "http") === FALSE)
echo '<a href="'.BASE_URL.'/0/tag/'.$palabra->textContent.'.html">'.$palabra->textContent.'</a> ';
}
echo '</div>';
echo '</div>';
}
}
function videoInfo()
{
$id = $this->video->getElementsByTagName("id")->item(0)->textContent;
$id = explode("/", $id);
$id = $id[6];
echo '<div class="video">';
$title = $this->video->getElementsByTagName("title")->item(0)->textContent;
$tiempo = $this->video->getElementsByTagNameNS("http://gdata.youtube.com/schemas/2007", "duration");
$tiempo = $tiempo->item(0)->getAttribute("seconds");
echo '<p class="links">'._DURATION.': '.minutes($tiempo).'</p>';
echo '<p>'.$this->video->getElementsByTagName("description")->item(0)->textContent.'</p>';
$tags = $this->video->getElementsByTagNameNS("http://www.w3.org/2005/Atom", "category");
echo '<div class="tags">'; echo 'tags: ';
foreach ($tags as $palabra)
{
if (strpos($palabra->getAttribute("term"), "http") === FALSE)
echo '<a href="'.BASE_URL.'/0/tag/'.$palabra->getAttribute("term").'.html">'.$palabra->getAttribute("term").'</a> ';
}
echo '</div>';
echo '</div>';
}
}
?> |
Partager