function searchRandomVideo($searchTerms) { global $maxSearchResults; //error_log("max results " . $maxSearchResults); $yt = new Zend_Gdata_YouTube(); $yt->setMajorProtocolVersion(2); $query = $yt->newVideoQuery(); // $query->setOrderBy('relevance'); // $query->setOrderBy('viewCount'); // $query->setOrderBy('random'); $query->setSafeSearch('none'); $query->setVideoQuery($searchTerms); $query->setMaxResults($maxSearchResults); // Note that we need to pass the version number to the query URL function // to ensure backward compatibility with version 1 of the API. $videoFeed = $yt->getVideoFeed($query->getQueryUrl(2)); // printVideoFeed($videoFeed, 'Search results for: ' . $searchTerms); $randVideoEntry = getRandomVideo($videoFeed); return $randVideoEntry; }
function getNewVideoJson($uname){ global $global_raw_videos_folder, $global_servers, $global_thumbs_folder; $newvid = array( "path" => $global_servers["SP"]."/".$global_raw_videos_folder."/". getRandomVideo($_SERVER["DOCUMENT_ROOT"]."/".$global_raw_videos_folder), "poster"=> NULL, "series"=> NULL, "uname" => $uname); return json_encode($newvid); }