コード例 #1
0
ファイル: search.php プロジェクト: nadu/open-captions
function searchAndPrint($searchTerms = 'sesame street')
{
    $yt = new Zend_Gdata_YouTube();
    $yt->setMajorProtocolVersion(2);
    $query = $yt->newVideoQuery();
    $query->setOrderBy('relevance');
    $query->setSafeSearch('moderate');
    $query->setVideoQuery($searchTerms);
    $query->setParam('caption', 'true');
    $query->setParam('start-index', $_GET['start_index']);
    $query->setParam('max-results', 8);
    //$query->setParam('max-results','2');
    // Note that we need to pass the version number to the query URL function
    // to ensure backward compatibility with version 1 of the API.
    //echo $query->getQueryUrl(2);
    //$videoFeed = $yt->getVideoFeed("http://gdata.youtube.com/feeds/api/videos?orderby=relevance&safeSearch=moderate&q=sesame+street");
    $videoFeed = $yt->getVideoFeed($query->getQueryUrl(2));
    $links = $videoFeed->getLink();
    $suggestFlag = null;
    foreach ($links as $link) {
        if ($link->getRel() == 'http://schemas.google.com/g/2006#spellcorrection') {
            $videoFeed = $yt->getVideoFeed($link->getHref());
            //print_r($link->getTitle());
            $suggestFlag = $link->getTitle();
            break;
        }
    }
    //if($links[1]){
    //}
    printVideoFeed($videoFeed, $suggestFlag);
    //'Search results for: ' . $searchTerms);
}
コード例 #2
0
function getAndPrintVideoFeed($location = Zend_Gdata_YouTube::VIDEO_URI)
{
    $yt = new Zend_Gdata_YouTube();
    // set the version to 2 to receive a version 2 feed of entries
    $yt->setMajorProtocolVersion(2);
    $videoFeed = $yt->getVideoFeed($location);
    printVideoFeed($videoFeed);
}
コード例 #3
0
ファイル: Video.php プロジェクト: EntityFX/QuikiJAR
 /**
  * Функция получения результатов поиска по серверу YT в виде объекта VideoFeed.
  * @param string $searchString строка поиска.
  * @return VideoFeed - возвращает объект VideoFeed 
  */
 function searchOnYT($searchString, $startID = 0)
 {
     $yt = new Zend_Gdata_YouTube($this->authYT($username, $password));
     $query = $yt->newVideoQuery();
     $query->videoQuery = $searchString;
     $query->startIndex = $startID;
     $query->maxResults = VideoThing::FILES_COUNT;
     $query->orderBy = 'viewCount';
     //echo $query->queryUrl . "\n <br />";
     $videoFeed = $yt->getVideoFeed($query);
     return $videoFeed;
 }
コード例 #4
0
ファイル: Util.php プロジェクト: kwylez/CW-Google
 /**
  * Retrieve video of based upon a given category
  *
  * @access public
  * @param int $maxResults
  * @return gVideo
  */
 public function getCategoryVideos($maxResults = 15)
 {
     if ($this->getCategory() == '') {
         throw new Exception("Empty categories are not allowed");
     } else {
         try {
             $yt = new Zend_Gdata_YouTube();
             $query = $yt->newVideoQuery();
             $query->category = $this->getCategory();
             $query->maxResults = $maxResults;
             $videoFeed = $yt->getVideoFeed($query);
             foreach ($videoFeed as $videoEntry) {
                 $gVideo = new CW_Google_Video_YouTube('', $videoEntry->mediaGroup->title->text, $videoEntry->getPublished(), $videoEntry->getId(), $videoEntry->updated->text, $videoEntry->mediaGroup->duration->seconds, $videoEntry->mediaGroup->content[0]->medium, $videoEntry->comments->feedLink->getHref(), $videoEntry->mediaGroup->content[0]->url, $videoEntry->mediaGroup->keywords->text, $videoEntry->mediaGroup->thumbnail[0]->url, $videoEntry->mediaGroup->thumbnail[0]->width, $videoEntry->mediaGroup->thumbnail[0]->height, $videoEntry->mediaGroup->thumbnail[0]->time, $videoEntry->mediaGroup->player[0]->url, $videoEntry->mediaGroup->category[0]->text, $videoEntry->getContent(), $videoEntry->mediaGroup->description->text, $videoEntry->getRating(), $videoEntry->getRacy(), $videoEntry->getStatistics()->getViewCount());
                 $this->setVideos($gVideo);
             }
         } catch (Zend_Gdata_App_Exception $ex) {
             print $ex->getMessage();
         } catch (Exception $e) {
             print $e->getMessage();
         }
     }
     return $this->getVideos();
 }
コード例 #5
0
 function video()
 {
     $videoId = $this->params['id'];
     $yt = new Zend_Gdata_YouTube();
     $entry = $yt->getVideoEntry($videoId);
     $this->set('videoTitle', $entry->mediaGroup->title);
     $this->set('description', $entry->mediaGroup->description);
     $this->set('authorUsername', $entry->author[0]->name);
     $this->set('authorUrl', 'http://www.youtube.com/profile?user='******'tags', $entry->mediaGroup->keywords);
     $this->set('duration', $entry->mediaGroup->duration->seconds);
     $this->set('watchPage', $entry->mediaGroup->player[0]->url);
     $this->set('viewCount', $entry->statistics->viewCount);
     $this->set('rating', $entry->rating->average);
     $this->set('numRaters', $entry->rating->numRaters);
     /* Get related Videos */
     $ytQuery = $yt->newVideoQuery();
     $ytQuery->setFeedType('related', $videoId);
     $ytQuery->setOrderBy('rating');
     $ytQuery->setMaxResults(5);
     $ytQuery->setFormat(5);
     $this->set('videoId', $videoId);
     $this->set('related', $yt->getVideoFeed($ytQuery));
 }
コード例 #6
0
ファイル: Content.php プロジェクト: xiaoguizhidao/bb
 public function getYoutubeVideoSuggestions()
 {
     if (Mage::helper('videogallery')->isVideoSuggestionsEnabled() == false) {
         return array();
     }
     if (!$this->_youtubeFeed) {
         try {
             $product = $this->getProduct();
             if (!$product->getId()) {
                 return array();
             }
             $yt = new Zend_Gdata_YouTube();
             $yt->getHttpClient()->setConfig(array('timeout' => 10));
             $query = $yt->newVideoQuery();
             $query->videoQuery = $product->getName() . ' ' . $product->getSku();
             $query->startIndex = 0;
             $query->maxResults = 5;
             $results = $yt->getVideoFeed($query);
             $this->_youtubeFeed = array();
             foreach ($results as $video) {
                 if ($this->videoAlreadyAdded($video->getVideoId())) {
                     continue;
                 }
                 $this->_youtubeFeed[] = $video;
             }
         } catch (Exception $e) {
             return "Error Retrieving Video Suggestions from Youtube: " . $e->getMessage();
         }
     }
     return $this->_youtubeFeed;
 }
コード例 #7
0
 /**
  * getvideoselectAction
  * @author Thomas Schedler <*****@*****.**>
  * @version 1.0
  */
 public function getvideoselectAction()
 {
     $this->core->logger->debug('core->controllers->VideoController->getvideoselectAction()');
     try {
         $arrVideos = array();
         $objRequest = $this->getRequest();
         $intChannelId = $objRequest->getParam('channelId');
         $strChannelUserId = $objRequest->getParam('channelUserId', '');
         $strElementId = $objRequest->getParam('elementId');
         $strValue = $objRequest->getParam('value');
         $strSearchQuery = $objRequest->getParam('searchString');
         switch ($intChannelId) {
             /*
              * Vimeo Controller
              */
             case $this->core->sysConfig->video_channels->vimeo->id:
                 /**
                  * Requires simplevimeo base class
                  */
                 require_once GLOBAL_ROOT_PATH . 'library/vimeo/vimeo.class.php';
                 $arrChannelUser = $this->core->sysConfig->video_channels->vimeo->users->user->toArray();
                 $intIdVideoType = 1;
                 if (array_key_exists('id', $arrChannelUser)) {
                     // Now lets do the user search query. We will get an response object containing everything we need
                     $objResponse = VimeoVideosRequest::getList($this->core->sysConfig->video_channels->vimeo->users->user->id);
                     // We want the result videos as an array of objects
                     $arrVideos = $objResponse->getVideos();
                 } else {
                     if ($strChannelUserId !== '') {
                         if (is_array($arrChannelUser)) {
                             foreach ($arrChannelUser as $chUser) {
                                 if ($chUser['id'] == $strChannelUserId) {
                                     // Now lets do the user search query. We will get an response object containing everything we need
                                     $objResponse = VimeoVideosRequest::getList($strChannelUserId);
                                     // We want the result videos as an array of objects
                                     $arrVideos = $objResponse->getVideos();
                                 }
                             }
                         }
                     }
                 }
                 // Set Channel Users
                 $this->view->channelUsers = array_key_exists('id', $arrChannelUser) ? array() : $this->core->sysConfig->video_channels->vimeo->users->user->toArray();
                 break;
                 /**
                  * Youtube Controller
                  */
             /**
              * Youtube Controller
              */
             case $this->core->sysConfig->video_channels->youtube->id:
                 $arrChannelUser = $this->core->sysConfig->video_channels->youtube->users->user->toArray();
                 $intIdVideoType = 2;
                 $objResponse = new Zend_Gdata_YouTube();
                 $objResponse->setMajorProtocolVersion(2);
                 if (array_key_exists('id', $arrChannelUser) && $strSearchQuery === '') {
                     $arrVideos = $objResponse->getuserUploads($this->core->sysConfig->video_channels->youtube->users->user->id);
                 } else {
                     if ($strChannelUserId !== '') {
                         $arrVideos = $objResponse->getuserUploads($strChannelUserId);
                     } else {
                         if ($strSearchQuery !== '') {
                             $query = $objResponse->newVideoQuery();
                             $query->setOrderBy('viewCount');
                             $query->setSafeSearch('none');
                             $query->setVideoQuery($strSearchQuery);
                             $arrVideos = $objResponse->getVideoFeed($query->getQueryUrl(2));
                         }
                     }
                 }
                 // Set Channel Users
                 $this->view->channelUsers = array_key_exists('id', $arrChannelUser) ? array() : $this->core->sysConfig->video_channels->youtube->users->user->toArray();
                 break;
         }
         $this->view->idVideoType = $intIdVideoType;
         $this->view->elements = $arrVideos;
         $this->view->channelUserId = $strChannelUserId;
         $this->view->value = $strValue;
         $this->view->elementId = $strElementId;
     } catch (Exception $exc) {
         $this->core->logger->err($exc);
         exit;
     }
 }
コード例 #8
0
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;
}
コード例 #9
0
ファイル: actions.class.php プロジェクト: nass600/homeCENTER
 public function executeSearchYoutube(sfWebRequest $request)
 {
     ini_set('display_errors', false);
     $util = new Util();
     $yt = new Zend_Gdata_YouTube();
     $yt->setMajorProtocolVersion(2);
     $query = $yt->newVideoQuery();
     $query->setSafeSearch('none');
     $query->setMaxResults(10);
     $query->setVideoQuery($request->getPostParameter('data'));
     // 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));
     $html = $util->printVideoFeed($videoFeed);
     echo $html;
     return sfView::NONE;
 }
コード例 #10
0
 function getRelevantVideos($searchTerms, $maxResults = 50)
 {
     if ($maxResults > 50) {
         $maxResults = 50;
         // No more than 50 results allowed by Youtube.com
     }
     try {
         $yt = new Zend_Gdata_YouTube();
         $yt->setMajorProtocolVersion(2);
         $query = $yt->newVideoQuery();
         $query->setOrderBy('relevance');
         $query->setSafeSearch('none');
         $query->setMaxResults($maxResults);
         $query->setVideoQuery($searchTerms);
         // 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));
         return $videoFeed;
     } catch (Zend_Gdata_App_HttpException $httpException) {
         //echo ("App HttpException Thrown<br>\n");
         $response = $httpException->getRawResponseBody();
     } catch (Zend_Gdata_App_Exception $e) {
         //echo ("App Exception Thrown<br>\n");
         $response = $e->getMessage();
     } catch (Exception $except) {
         //echo ("Exception Thrown<br>\n");
         $response = $except->getMessage();
     }
     echo "Error: {$response}<br>";
     return null;
 }
コード例 #11
0
ファイル: app.youtube.php プロジェクト: sjlu/fb-music-app
 */
if (isset($_GET['search'])) {
    /*
     * Loading the Zend GDATA API.
     */
    require_once 'Zend/Loader.php';
    Zend_Loader::loadClass('Zend_Gdata_YouTube');
    Zend_Loader::loadClass('Zend_Gdata_AuthSub');
    Zend_Loader::loadClass('Zend_Gdata_App_Exception');
    $youTubeService = new Zend_Gdata_YouTube();
    $query = $youTubeService->newVideoQuery();
    $query->setQuery($_POST['search']);
    $query->setStartIndex(0);
    $query->setMaxResults(9);
    $query->setFormat('5');
    $feed = $youTubeService->getVideoFeed($query);
    /* Grabs the data received from Gdata and converts it into a nice array
    	for people like me to work with. Its just so I handle the data better.
    	It basically puts in the title of the video, the ID of the video,
    	the link to the video and the URL of the largest thumbnail possible */
    $i = 0;
    $youtubeData = array();
    foreach ($feed as $entry) {
        $youtubeData[$i]['title'] = $entry->getVideoTitle();
        $youtubeData[$i]['id'] = $entry->getVideoId();
        $youtubeData[$i]['video'] = $entry->getFlashPlayerUrl();
        $thumbnail = $entry->getVideoThumbnails();
        $youtubeData[$i]['img'] = $thumbnail[2]['url'];
        $i++;
    }
    //end data parsing
コード例 #12
0
ファイル: crawler.php プロジェクト: Zipcore/SSMS
$matches = array();
$result = mysql_query("SELECT * FROM matchids WHERE " . $crawl_string . " or sessionid = 680462533 LIMIT 0, 10");
while ($row = mysql_fetch_array($result)) {
    if ($row['sessionid'] > 1000000) {
        $matches["match_" . strtolower(dechex($row['sessionid']))] = $row;
    }
}
echo 'Crawling ' . count($matches) . ' match(es)<br/>';
$matchlist = implode(' | ', array_keys($matches));
if (empty($matchlist)) {
    die;
}
echo $matchlist . "<br/>";
$query = $yt->newVideoQuery();
$query->setVideoQuery($matchlist);
$query->setMaxResults(50);
$videoFeed = $yt->getVideoFeed($query->getQueryUrl(2));
foreach ($videoFeed as $videoEntry) {
    preg_match_all("/(Scout|Soldier|Pyro|Demoman|Heavy|Engineer|Medic|Sniper|Spy)|match_([0-9a-f]{6,})/", implode("|", $videoEntry->getVideoTags()), $matchid);
    $authobj = $videoEntry->getAuthor();
    $matchinfo = $matches[$matchid[0][1]];
    if (mysql_num_rows(mysql_query("SELECT youtubeid FROM videos WHERE youtubeid = '" . $videoEntry->getVideoId() . "'")) != 0) {
        mysql_query("UPDATE videos SET title = '" . mysql_real_escape_string($videoEntry->getVideoTitle()) . "', description = '" . mysql_real_escape_string($videoEntry->getVideoDescription()) . "' WHERE youtubeid = '" . $videoEntry->getVideoId() . "'");
        echo mysql_error();
    } else {
        $nextmatch = mysql_fetch_array(mysql_query("SELECT * FROM matchids WHERE matchdate > '" . $matchinfo['matchdate'] . "' AND serverid = " . $matchinfo['serverid'] . " LIMIT 1"));
        mysql_query("INSERT INTO videos ( youtubeid, youtubeuser, map, sessionid, matchdate, matchduration, role, serverid, duration, title, description ) VALUES ( '" . $videoEntry->getVideoId() . "', '" . $authobj[0]->getName() . "', '" . $matchinfo['mapname'] . "', '" . $matchinfo['sessionid'] . "', '" . $matchinfo['matchdate'] . "', '" . (strtotime($nextmatch['matchdate']) - strtotime($matchinfo['matchdate'])) . "', '" . $matchid[0][0] . "', '" . $matchinfo['serverid'] . "', '" . $videoEntry->getVideoDuration() . "', '" . mysql_real_escape_string($videoEntry->getVideoTitle()) . "', '" . mysql_real_escape_string($videoEntry->getVideoDescription()) . "' )");
        echo mysql_error();
        $yt->insertEntry($videoEntry, $yt->getUserFavorites("LethalZone")->getSelfLink()->href);
    }
}
コード例 #13
0
ファイル: get_youtubeIDs.php プロジェクト: pushpen/class2go
require_once '/usr/share/php/libzend-framework-php/Zend/Gdata/YouTube.php';
// Enter your Google account credentials
$username = '******';
$passwd = 'Iks0jfisdf0mq2KKx';
$authenticationURL = 'https://www.google.com/accounts/ClientLogin';
try {
    $httpClient = Zend_Gdata_ClientLogin::getHttpClient($username, $passwd, $service = 'youtube', $client = null, $source = 'MySource', $loginToken = null, $loginCaptcha = null, $authenticationURL);
} catch (Zend_Gdata_App_CaptchaRequiredException $cre) {
    echo 'URL of CAPTCHA image: ' . $cre->getCaptchaUrl() . "\n";
    echo 'Token ID: ' . $cre->getCaptchaToken() . "\n";
} catch (Zend_Gdata_App_AuthException $ae) {
    echo 'Problem authenticating: ' . $ae->exception() . "\n";
}
$developerKey = "AI39si6XnLpHKQofAlknA2RvYaGTmAIi3oaaF06IT7ibI_2QM-M_QSdoD9bPZ5AIiqfKceCETIhZg1smyIc8yFhBawS9zoCFnA";
$applicationId = "Online Course";
$clientId = "";
$yt = new Zend_Gdata_YouTube($httpClient, $applicationId, $clientId, $developerKey);
$yt->setMajorProtocolVersion(2);
$query = $yt->newVideoQuery();
$query->setAuthor($username);
$query->setMaxResults(50);
//echo $query->getQueryUrl(2);
$start = 1;
while ($start % 50 == 1) {
    $feed = $yt->getVideoFeed("http://gdata.youtube.com/feeds/api/users/default/uploads?max-results=50&start-index=" . $start);
    foreach ($feed as $video) {
        echo $video->getVideoId() . ":" . $video->getVideoTitle() . " \n";
        file_put_contents($video->getVideoTitle() . '/vidID.json', json_encode($video->getVideoID()));
        $start++;
    }
}
コード例 #14
0
ファイル: index.php プロジェクト: ufwebadmin/MIT-Mobile-Web
// libs
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata_YouTube');
require_once "lib/youtube.lib.inc.php";
require_once $library_path . DIRECTORY_SEPARATOR . 'cache.php';
if ((int) $_REQUEST['page'] != 0) {
    $prev = $_REQUEST['page'] - 1;
    $next = $_REQUEST['page'] + 1;
    $index = $_REQUEST['page'] * 5 - 4;
} else {
    $next = 2;
    $index = 1;
}
$yt = new Zend_Gdata_YouTube();
$yt->setMajorProtocolVersion(2);
$query = $yt->newVideoQuery();
$query->setMaxResults(5);
$query->setAuthor($youtube_user);
$query->setOrderBy('updated');
$query->setStartIndex($index);
$cache = mwosp_get_cache();
$cache_id = md5($query->getQueryUrl());
$uploads = array();
// XXX: Workaround for deserialization
Zend_Loader::loadClass('Zend_Http_Client_Adapter_Socket');
if (($uploads = $cache->load($cache_id)) === false) {
    $uploads = $yt->getVideoFeed($query);
    $cache->save($uploads, $cache_id);
}
require "templates/{$prefix}/index.html";
$page->output();
コード例 #15
0
 function searchAndPrint($searchTerms = '')
 {
     $yt = new Zend_Gdata_YouTube();
     $yt->setMajorProtocolVersion(2);
     $query = $yt->newVideoQuery();
     $query->setOrderBy('relevance');
     $query->setSafeSearch('none');
     $query->setVideoQuery($searchTerms);
     // 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));
     $this->printVideoFeed($videoFeed, 'Search results for: ' . $searchTerms);
 }
コード例 #16
0
ファイル: YouTube.php プロジェクト: hackingman/TubeX
 public function Test()
 {
     $yt = new Zend_Gdata_YouTube();
     $video_feed = $yt->getVideoFeed($this->feed['feed_url']);
 }
コード例 #17
0
ファイル: YouTubeOnlineTest.php プロジェクト: netvlies/zf
 public function testCommentOnAComment()
 {
     $developerKey = constant('TESTS_ZEND_GDATA_YOUTUBE_DEVELOPER_KEY');
     $clientId = constant('TESTS_ZEND_GDATA_YOUTUBE_CLIENT_ID');
     $client = Zend_Gdata_ClientLogin::getHttpClient($this->user, $this->pass, 'youtube', null, 'ZF_UnitTest', null, null, 'https://www.google.com/youtube/accounts/ClientLogin');
     $youtube = new Zend_Gdata_YouTube($client, 'ZF_UnitTest', $clientId, $developerKey);
     $youtube->setMajorProtocolVersion(2);
     $mostDiscussedFeed = $youtube->getVideoFeed('http://gdata.youtube.com/feeds/api/standardfeeds/most_discussed');
     // get first entry
     $mostDiscussedFeed->rewind();
     $firstEntry = $mostDiscussedFeed->current();
     $this->assertTrue($firstEntry instanceof Zend_Gdata_YouTube_VideoEntry);
     $commentFeed = $youtube->getVideoCommentFeed($firstEntry->getVideoId());
     // get first comment
     $commentFeed->rewind();
     $firstCommentEntry = $commentFeed->current();
     $commentedComment = $youtube->replyToCommentEntry($firstCommentEntry, 'awesome ! (ZFUnitTest-test)');
     $this->assertTrue($commentedComment instanceof Zend_Gdata_YouTube_CommentEntry);
 }
コード例 #18
0
ファイル: mashup.php プロジェクト: simonescu/mashupkeyword
 /**
  * youtube search
  * using Zend_Gdate_YouTube() class
  *
  */
 public function youtubeSearch($keyword = null, $per_page = '25', $start_index = '1')
 {
     $yt = new Zend_Gdata_YouTube();
     $yt_query = $yt->newVideoQuery();
     $yt_query->videoQuery = urlencode($keyword);
     $yt_query->startIndex = $start_index;
     $yt_query->maxResults = $per_page;
     $yt_query->orderBy = 'viewCount';
     $yt_query->Format = '5';
     $request = $yt->getVideoFeed($yt_query);
     if (!$request) {
         throw new Exception("There was an error loading the youtubeSearch Data ");
     }
     return $request;
 }
コード例 #19
0
 /**
  * getvideoselectAction
  * @author Thomas Schedler <*****@*****.**>
  * @version 1.0
  */
 public function getvideoselectAction()
 {
     $this->core->logger->debug('core->controllers->VideoController->getvideoselectAction()');
     try {
         $arrVideos = array();
         $objRequest = $this->getRequest();
         $intChannelId = $objRequest->getParam('channelId');
         $strChannelUserId = $objRequest->getParam('channelUserId');
         $strElementId = $objRequest->getParam('elementId');
         $strValue = $objRequest->getParam('value');
         $strSearchQuery = $objRequest->getParam('searchString');
         switch ($intChannelId) {
             /*
              * Vimeo Controller
              */
             case $this->core->sysConfig->video_channels->vimeo->id:
                 /**
                  * Requires simplevimeo base class
                  */
                 require_once GLOBAL_ROOT_PATH . 'library/vimeo/vimeo.class.php';
                 $arrChannelUser = $this->core->sysConfig->video_channels->vimeo->users->user->toArray();
                 $intVideoTypeId = 1;
                 $arrVideos = array();
                 /**
                  * Get the vimeo video list
                  */
                 if ($strChannelUserId !== '' && $strChannelUserId !== 'publicAccess' && $strSearchQuery == '') {
                     if (is_array($arrChannelUser)) {
                         foreach ($arrChannelUser as $chUser) {
                             if ($chUser['id'] == $strChannelUserId) {
                                 $objResponse = VimeoVideosRequest::getList($strChannelUserId);
                             }
                         }
                     }
                     $arrVideos = $objResponse->getVideos();
                 } else {
                     if ($strChannelUserId !== '' && isset($strSearchQuery)) {
                         if ($strChannelUserId == 'publicAccess') {
                             $objResponse = VimeoVideosRequest::search($strSearchQuery);
                         } else {
                             $objResponse = VimeoVideosRequest::search($strSearchQuery, $strChannelUserId);
                         }
                         $arrVideos = $objResponse->getVideos();
                     }
                 }
                 // Set channel Users
                 $this->view->channelUsers = array_key_exists('id', $arrChannelUser) ? array(0 => $arrChannelUser) : $this->core->sysConfig->video_channels->vimeo->users->user->toArray();
                 break;
                 /**
                  * Youtube Controller
                  */
             /**
              * Youtube Controller
              */
             case $this->core->sysConfig->video_channels->youtube->id:
                 $arrChannelUser = $this->core->sysConfig->video_channels->youtube->users->user->toArray();
                 $intVideoTypeId = 2;
                 $objResponse = new Zend_Gdata_YouTube();
                 $objResponse->setMajorProtocolVersion(2);
                 if ($strChannelUserId !== '' && $strSearchQuery == '' && $strChannelUserId !== 'publicAccess') {
                     $arrVideos = $objResponse->getuserUploads($strChannelUserId);
                 } else {
                     if (isset($strChannelUserId) && isset($strSearchQuery)) {
                         if ($strChannelUserId !== 'publicAccess') {
                             $arrVideos = $objResponse->getVideoFeed('http://gdata.youtube.com/feeds/api/users/' . $strChannelUserId . '/uploads?q=' . urlencode($strSearchQuery));
                         } else {
                             $objQuery = $objResponse->newVideoQuery();
                             $objQuery->setOrderBy('viewCount');
                             $objQuery->setSafeSearch('none');
                             $objQuery->setVideoQuery($strSearchQuery);
                             $arrVideos = $objResponse->getVideoFeed($objQuery->getQueryUrl(2));
                         }
                     }
                 }
                 // Set Channel Users
                 $this->view->channelUsers = array_key_exists('id', $arrChannelUser) ? array(0 => $arrChannelUser) : $this->core->sysConfig->video_channels->youtube->users->user->toArray();
                 break;
         }
         $this->view->videoTypeId = $intVideoTypeId;
         $this->view->elements = $arrVideos;
         $this->view->channelUserId = $strChannelUserId;
         $this->view->value = $strValue;
         $this->view->elementId = $strElementId;
         $this->view->SearchQuery = $strSearchQuery;
     } catch (Exception $exc) {
         $this->core->logger->err($exc);
         exit;
     }
 }
コード例 #20
0
/**
 * Returns a feed of top rated videos for the specified user
 *
 * @param string $user The username
 * @return Zend_Gdata_YouTube_VideoFeed The feed of top rated videos
 */
function getTopRatedVideosByUser($user)
{
    $userVideosUrl = 'http://gdata.youtube.com/feeds/users/' . $user . '/uploads';
    $youTubeService = new Zend_Gdata_YouTube();
    $ytQuery = $youTubeService->newVideoQuery($userVideosUrl);
    // order by the rating of the videos
    $ytQuery->setOrderBy('rating');
    // retrieve a maximum of 5 videos
    $ytQuery->setMaxResults(5);
    // retrieve only embeddable videos
    $ytQuery->setFormat(5);
    return $youTubeService->getVideoFeed($ytQuery);
}
コード例 #21
0
function player_shortcode($atts)
{
    $username = get_option('youtube_user');
    //gets the username that was entered in the admin screen
    //declares the attributes for the video player shortcode
    $atts = shortcode_atts(array('width' => '450', 'height' => '253', 'videocode' => '', 'description' => 'yes', 'title' => 'yes', 'descriptionlength' => '1000', 'classname' => ''), $atts);
    global $descriptionlength;
    //makes $descriptionlength a global variable so the right length descriptions can be passed from the feed function
    $descriptionlength = $atts['descriptionlength'];
    //assigns $descriptionlength the desired value.
    //YouTube classes for Gdata
    $yt = new Zend_Gdata_YouTube();
    $yt->setMajorProtocolVersion(2);
    //if there is a defined video to display on page load, load that video.
    if ($atts['videocode'] != '') {
        $videoEntry = $yt->getVideoEntry($atts['videocode']);
        //get Gdata for all the desired video
        $descriptionlong = $videoEntry->getVideoDescription();
        $description = substr($descriptionlong, 0, $atts['descriptionlength']) . "...";
        //description set to the desired length
        //print HTML for the video player
        $videoplayer = '<div id="playerchart" class="' . $atts['classname'] . '" >';
        if ($atts['title'] == 'yes' || $atts['title'] == 'true') {
            $videoplayer = $videoplayer . '<div id="titlediv" ><b class="title_player" id="title_player">' . $titleplayer . '</b></div>';
        }
        $videoplayer = $videoplayer . '<div class="video_player"><iframe width="' . $atts['width'] . '" height="' . $atts['height'] . '" id="playingvideo" src="http://www.youtube.com/embed/' . $atts['videocode'] . '" frameborder="0" allowfullscreen></iframe></div>';
        if ($atts['description'] == 'yes' || $atts['description'] == 'true') {
            $videoplayer = $videoplayer . '<div class="player_description" id="player_description">' . $description . '</div>';
        }
        $videoplayer = $videoplayer . '</div>';
        return $videoplayer;
        goto a;
        //skip out the rest of the function
    } else {
        $url = 'http://gdata.youtube.com/feeds/api/users/' . $username . '/uploads?orderby=viewCount&max-results=1';
        //url for video feed of one video
    }
    Zend_Loader::loadClass('Zend_Gdata_YouTube');
    $videoFeed = @$yt->getVideoFeed($url);
    //create feed from URL
    //loop through feed
    foreach ($videoFeed as $videoEntry) {
        $descriptionlong = $videoEntry->getVideoDescription();
        //get video description
        $titleplayer = $videoEntry->getVideoTitle();
        //get video title
        //change video length if longer than desired amount
        if (strlen($descriptionlong) > $atts['descriptionlength']) {
            $descriptionlong = $videoEntry->getVideoDescription();
            $description = substr($descriptionlong, 0, $atts['descriptionlength']) . "...";
            //... to the end of cut description
        } else {
            $description = $videoEntry->getVideoDescription();
            //if description is shorter than maximum amount assign full description
        }
        //print video player from feed data
        $videoplayer = '<div id="playerchart" class="' . $atts['classname'] . '" >';
        $videoplayer = $videoplayer . '<div id="titlediv" ><b id="title_player">' . $titleplayer . '</b></div>';
        $videoplayer = $videoplayer . '<div style="margin-right:20px;"><iframe width="450" height="253" id="playingvideo" src="http://www.youtube.com/embed/' . $videoEntry->getVideoId() . '" frameborder="0" allowfullscreen></iframe></div>';
        $videoplayer = $videoplayer . '<div id="player_description">' . $description . '</div>';
        $videoplayer = $videoplayer . '</div>';
        return $videoplayer;
        break;
        //end the loop after one cycle to make sure only one player appears.
    }
    a:
    //where the process skips to if specific video is defined for page load.
}
コード例 #22
0
ファイル: index.php プロジェクト: jorgenils/zend-framework
/**
 * Returns a feed of videos related to the specified video
 *
 * @param string $videoId The video
 * @return Zend_Gdata_YouTube_VideoFeed The feed of related videos
 */
function getRelatedVideos($videoId) 
{
    $yt = new Zend_Gdata_YouTube();
    $ytQuery = $yt->newVideoQuery();
    // show videos related to the specified video
    $ytQuery->setFeedType('related', $videoId);
    // order videos by rating
    $ytQuery->setOrderBy('rating');
    // retrieve a maximum of 5 videos
    $ytQuery->setMaxResults(5);
    // retrieve only embeddable videos
    $ytQuery->setFormat(5);
    return $yt->getVideoFeed($ytQuery);
}
コード例 #23
0
ファイル: YoutubeService.php プロジェクト: uhdyi/blacklist
function searchYoutube($cat, $searchTerm, $page, $queryType, $maxResults, $startIndex)
{
    $retval = array();
    $data = array();
    if ($queryType === null) {
        /* display the entire interface */
        include '../home.html';
    } else {
        if ($queryType == 'show_video') {
            /* display an individual video */
            if (array_key_exists('videoId', $_REQUEST)) {
                $videoId = $_REQUEST['videoId'];
                $data = echoVideoPlayer($videoId);
            } else {
                echo 'No videoId found.';
                exit;
            }
        } else {
            /* display a list of videos */
            //$searchTerm = $_REQUEST['searchTerm'];
            //$startIndex = $_REQUEST['startIndex'];
            //$maxResults = $_REQUEST['maxResults'];
            $yt = new Zend_Gdata_YouTube();
            $query = $yt->newVideoQuery();
            $query->setQuery($searchTerm);
            $query->setStartIndex($startIndex);
            $query->setMaxResults($maxResults);
            //print_r($query);
            /* check for one of the standard feeds, or list from 'all' videos */
            switch ($queryType) {
                case 'most_viewed':
                    $query->setFeedType('most viewed');
                    $query->setTime('this_week');
                    $feed = $yt->getVideoFeed($query);
                    break;
                case 'most_recent':
                    $query->setFeedType('most recent');
                    $feed = $yt->getVideoFeed($query);
                    break;
                case 'recently_featured':
                    $query->setFeedType('recently featured');
                    $feed = $yt->getVideoFeed($query);
                    break;
                case 'top_rated':
                    $query->setFeedType('top rated');
                    $query->setTime('this_week');
                    $feed = $yt->getVideoFeed($query);
                    break;
                case 'all':
                    $feed = $yt->getVideoFeed($query);
                    break;
                default:
                    echo 'ERROR - unknown queryType - "' . $queryType . '"';
                    break;
            }
            $data = echoVideoList($feed);
            //youtube won't allow search item beyond 1000, namely no page beyond 100 if 10 items/page.
            $totalpages = min(100, $feed->getTotalResults()->text);
        }
    }
    $retval['status'] = 'OK';
    $retval['statusmsg'] = 'OK';
    $retval['data'] = $data;
    $retval['totalpages'] = $totalpages;
    return $retval;
}