0

我使用 Zend_Gdata_YouTube(); 从频道中检索播放列表,但其中一些包含已删除或私人视频。当我将提要传递给

 new Zend_Paginator(new Lib_Paginator_Adapter_YoutubePlaylist($playlistData[$playlistParam]['feedUrl']));

它还计算已删除和私人视频,这就是出现 0 元素页面的原因。如何按隐私/存在创建查询或过滤结果?

$paginator = new Zend_Paginator(new Lib_Paginator_Adapter_YoutubePlaylist($playlistData[$playlistParam]['feedUrl']));
$videos = $yt->getPlaylistVideoFeed($playlistData[$playlistParam]['feedUrl']);

谢谢。

更新 :

$username = $this->config->youtube->username;
        $yt = new Zend_Gdata_YouTube();
        $yt->setMajorProtocolVersion(2);

    $playlistData = array();
    $playlistData['uploads'] = array(
        'title' => 'Uploads'
    );
    $playlists = $yt->getPlaylistListFeed($username);
    foreach ($playlists as $playlist) {
        $playlistId = $this->getPlaylistId($playlist->id);
        $playlistData[$playlistId] = array(
            'title' => $playlist->title->text,
            'feedUrl' => $playlist->getPlaylistVideoFeedUrl()
        );
    }

    $playlistParam = $this->getRequest()->getParam('playlist');
    if (!$playlistParam) {
        $playlistParam = 'uploads';
    }

    if ($playlistParam != 'uploads') {
        $paginator = new Zend_Paginator(new Lib_Paginator_Adapter_YoutubePlaylist($playlistData[$playlistParam]['feedUrl']));
        $videos = $yt->getPlaylistVideoFeed($playlistData[$playlistParam]['feedUrl']);
    } else {
        $paginator = new Zend_Paginator(new Lib_Paginator_Adapter_YoutubeUser($username));
        $videos = $yt->getUserUploads($username);
    }

    $data = array();
    foreach ($videos as $video) {
        $thumbnails = $video->getVideoThumbnails();
        $data[] = array(
            'id' => $this->getVideoId($video->getVideoWatchPageUrl()),
            'thumb' => $thumbnails[0]['url'],
            'title' => $video->getVideoTitle(),
            'published' => $video->getPublished()->getText(),
            'description' => $video->getVideoDescription()
        );
        break;
    }
4

1 回答 1

0

您希望根据yt:state的存在进行查询,如果状态标签存在,则文件由于某种原因受到限制。您还可以在ZF gData和查看Zend_Gdata_YouTube_Extension_State. 您没有包含足够多的代码,我无法就如何调整代码提供更多建议。

祝你好运! [编辑] 最好的猜测是添加一个 videoQuery 代替 getPlaylistFeed() 或作为 getPlaylistFeed() 的一部分:

$query = new Zend_Gdata_YouTube_VideoQuery();
$query->setParam('state', 0);//you may need to query for all of your videos this way.

抱歉,我帮不上忙,但这个 api 看起来像一团糟。

于 2012-08-17T10:32:51.480 回答