我使用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;
}
答案 0 :(得分:0)
您希望根据yt:state的存在进行查询,如果状态标记存在,则文件因某种原因受到限制。您还可以在ZF gData找到一些有用的信息,并查看Zend_Gdata_YouTube_Extension_State
中的代码。您没有为我提供足够的代码来提供有关如何调整代码的更多建议。
$query = new Zend_Gdata_YouTube_VideoQuery();
$query->setParam('state', 0);//you may need to query for all of your videos this way.
对不起,我无能为力,但这个api看起来像乱七八糟的混乱。