【发布时间】:2012-08-17 09:37:51
【问题描述】:
我使用 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;
}
【问题讨论】:
标签: php zend-framework youtube youtube-api