我使用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;
}
您希望根据yt:state的存在进行查询,如果state标记存在,则文件由于某种原因受到限制。您还可以在ZF gData和Zend_Gdata_YouTube_Extension_State
中的代码中找到一些有用的信息。你还没有包含足够的代码,我无法就如何调整你的代码提供更多建议。
祝你好运![EDIT]最好的猜测是添加一个videoQuery来代替getPlaylistFeed()或作为其一部分:
$query = new Zend_Gdata_YouTube_VideoQuery();
$query->setParam('state', 0);//you may need to query for all of your videos this way.
抱歉,我帮不了更多的忙,但这个api看起来一团糟。