/**
  * get videos favorited by username
  * @param string $username
  * @return Zend_Gdata_YouTube_VideoFeed 
  */
 public function getFavoritesByUser($user, $page = 0)
 {
     /* @var $ytq Zend_Gdata_YouTube_VideoQuery */
     $ytq = $this->yt->newVideoQuery(Zend_Gdata_YouTube::USER_URI . '/' . $user . '/' . Zend_Gdata_YouTube::FAVORITES_URI_SUFFIX);
     $page = $page * self::ITEMS_PER_PAGE;
     $ytq->setStartIndex($page == 0 ? $page : $page + 1);
     $ytq->setMaxResults(self::ITEMS_PER_PAGE);
     $ytq->setOrderBy('published');
     return $this->yt->getUserFavorites(null, $ytq);
 }
Exemple #2
0
$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);
    }
}