Exemplo n.º 1
0
 public function testGetVideoTags()
 {
     $this->entry->transferFromXML($this->entryText);
     $videoEntry = $this->entry;
     $keywords = $videoEntry->getMediaGroup()->getKeywords();
     $keywordsString = (string) $keywords;
     if (strlen(trim($keywordsString)) > 0) {
         $keywordArray = split('(, *)|,', $keywordsString);
     }
     $tagArray = $videoEntry->getVideoTags();
     $this->assertEquals(count($keywordArray), count($tagArray));
     foreach ($keywordArray as $keyword) {
         $this->assertTrue(in_array($keyword, $tagArray));
     }
     foreach ($tagArray as $tag) {
         $this->assertTrue(in_array($tag, $keywordArray));
     }
     $newEntry = new Zend_Gdata_YouTube_VideoEntry();
     $this->assertEquals(array(), $newEntry->getVideoTags());
 }
/**
 * Echo video metadata
 *
 * @param Zend_Gdata_YouTube_VideoEntry $entry The video entry
 * @return void
 */
function echoVideoMetadata($entry)
{
    $title = htmlspecialchars($entry->getVideoTitle());
    $description = htmlspecialchars($entry->getVideoDescription());
    $authorUsername = htmlspecialchars($entry->author[0]->name);
    $authorUrl = 'http://www.youtube.com/profile?user='******', ', $entry->getVideoTags()));
    $duration = htmlspecialchars($entry->getVideoDuration());
    $watchPage = htmlspecialchars($entry->getVideoWatchPageUrl());
    $viewCount = htmlspecialchars($entry->getVideoViewCount());
    $rating = 0;
    if (isset($entry->rating->average)) {
        $rating = $entry->rating->average;
    }
    $numRaters = 0;
    if (isset($entry->rating->numRaters)) {
        $numRaters = $entry->rating->numRaters;
    }
    $flashUrl = htmlspecialchars(findFlashUrl($entry));
    print <<<END
        <b>Title:</b> {$title}<br />
        <b>Description:</b> {$description}<br />
        <b>Author:</b> <a href="{$authorUrl}">{$authorUsername}</a><br />
        <b>Tags:</b> {$tags}<br />
        <b>Duration:</b> {$duration} seconds<br />
        <b>View count:</b> {$viewCount}<br />
        <b>Rating:</b> {$rating} ({$numRaters} ratings)<br />
        <b>Flash:</b> <a href="{$flashUrl}">{$flashUrl}</a><br />
        <b>Watch page:</b> <a href="{$watchPage}">{$watchPage}</a> <br />
END;
}
Exemplo n.º 3
0
 public function testSetVideoTags()
 {
     $this->entry->transferFromXML($this->entryText);
     $videoEntry = $this->entry;
     $newKeywordsString = $this->createRandomString() . ', ' . $this->createRandomString();
     $videoEntry->setVideoTags($newKeywordsString);
     if (strlen(trim($newKeywordsString)) > 0) {
         $keywordArray = split('(, *)|,', $newKeywordsString);
     }
     $tagArray = $videoEntry->getVideoTags();
     $this->assertEquals(count($keywordArray), count($tagArray));
     foreach ($keywordArray as $keyword) {
         $this->assertTrue(in_array($keyword, $tagArray));
     }
     foreach ($tagArray as $tag) {
         $this->assertTrue(in_array($tag, $keywordArray));
     }
     $newEntry = new Zend_Gdata_YouTube_VideoEntry();
     $this->assertEquals(array(), $newEntry->getVideoTags());
 }