All pastes #736580 Raw Edit

Stuff

public php v1 · immutable
·published 2007-10-14 17:44 UTC
rendered paste body
/** * Returns an array with the video's information * @param $vid * @return $info */function getVideoInfo($vid){  global $config;  $info = array();    if( ! $xml_v = @simplexml_load_file($config['api_url']."/{$vid}"))  {    return FALSE;  }    $info['title'] = trim($xml_v->title);    $namespaces_v = $xml_v->getNamespaces(TRUE);    $ns_yt = $xml_v->children($namespaces_v['yt']);  $ns_yt_attrib = $ns_yt->attributes();  $info['views'] = (integer) $ns_yt_attrib['viewCount'];    $ns_gd = $xml_v->children($namespaces_v['gd']);  $ns_gd_attrib = $ns_gd->attributes();  $info['rating'] = (float) roundNumber( (float) $ns_gd_attrib['average']);  $info['numofratings'] = (integer) $ns_gd_attrib['numRaters'];    $xml_c = simplexml_load_file($config['api_url']."/{$vid}/comments");  $namespaces_c = $xml_c->getNamespaces(TRUE);    $ns_openSearch = $xml_c->children($namespaces_c['openSearch']);  $info['comments'] = (integer) $ns_openSearch->totalResults;    if($info['numofratings'] == 0)  {    $info['rating'] = 'NULL';    $info['numofratings'] = 'NULL';  }    return $info;}