'published', 'viewCount', 'rating', 'relevance');
// generate feed URL
$feedURL = "http://gdata.youtube.com/feeds/api/videos/-/{$q}?orderby={$arr_orderby[$order_item]}&max-results={$max}";
// read feed into SimpleXML object
$sxml = simplexml_load_file($feedURL);
// get summary counts from opensearch: namespace
$counts = $sxml->children('http://a9.com/-/spec/opensearchrss/1.0/');
$total = $counts->totalResults;
$startOffset = $counts->startIndex;
$endOffset = ($startOffset-1) + $counts->itemsPerPage;
?>
entry as $entry) {
// get nodes in media: namespace for media information
$media = $entry->children('http://search.yahoo.com/mrss/');
// get video player URL
$attrs = $media->group->player->attributes();
$watch = $attrs['url'];
$videoid = substr($watch, strrpos($watch,'v=')+2, strlen($watch));
$auxPos = strpos($videoid,'&feature');
$videoid = substr($videoid,0,$auxPos);
// get video thumbnail
$attrs = $media->group->thumbnail[0]->attributes();
$thumbnail = $attrs['url'];
// get node for video length
$yt = $media->children('http://gdata.youtube.com/schemas/2007');
$attrs = $yt->duration->attributes();
$length = $attrs['seconds'];
// get node for video ratings
$gd = $entry->children('http://schemas.google.com/g/2005');
if ($gd->rating) {
$attrs = $gd->rating->attributes();
$rating = $attrs['average'];
} else {
$rating = 0;
}
// store record
$videoThumb[$i]=$thumbnail;
$videoTitle[$i]=$media->group->title;
$videoDesc[$i]=$media->group->description;
$videoId[$i]=$videoid;
$i++;
}
$totalVids=($i>0?$i:0);
$totalPages=round($totalVids/$rpp);
$page=(is_numeric($_GET['start'])?$_GET['start']:1);
$start=($page-1)*$rpp;
$end=($start+$rpp<$max?$start+$rpp:$max);
for($i=$start;$i<$end;$i=$i+2)
{
?>
|
|
|
|
|
|
|