如何检索YouTube用户列表';播放列表列出超过25条记录。YouTube API v2,C#
如何检索YouTube用户超过25条记录的播放列表。 YouTube API v2,C# 我所做的:如何检索YouTube用户列表';播放列表列出超过25条记录。YouTube API v2,C#,c#,youtube-api,C#,Youtube Api,如何检索YouTube用户超过25条记录的播放列表。 YouTube API v2,C# 我所做的: Feed<Playlist> userPlaylists = request.GetPlaylistsFeed(youtubeUserID); //i.e youtubeUserID = hollywoodlife09 foreach (Playlist playlistInfo in userPlaylist
Feed<Playlist> userPlaylists = request.GetPlaylistsFeed(youtubeUserID);
//i.e youtubeUserID = hollywoodlife09
foreach (Playlist playlistInfo in userPlaylists.Entries)
{
//work with playlist id.
GetOtherVideosOfThisPlaylistId(playlistEntryUri.Segments[6]);
//Segments[6] : it contain playlistId , i.e : "LL2rJLq19N0dGrxfib80M_fg"
}
Feed userPlaylists=request.getplaylistfeed(youtubeUserID);
//i、 e youtubeueserid=hollywoodlife09
foreach(userPlaylists.Entries中的playlistplaylistinfo)
{
//使用播放列表id。
GetOtherVideoSoftHisPlayId(playEntryUri.Segments[6]);
//段[6]:包含播放ID,即:“LL2rJLq19N0dGrxfib80M_fg”
}
问题:工作正常,但在这里我只能获得25条YouTube用户播放列表的记录。。无法设置开始索引或其他内容,以便使用提要所以,任何人都知道如何获取其他记录。首先获取所有playlid,然后,使用youtubeAPI再次使用Evryplaylid cron它
try
{
YouTubeRequestSettings settings = new YouTubeRequestSettings("YoutubeLibrary", DeveloperKey);
settings.Timeout = 120000;
int start = 1;
int maxResult = 50;
int totalVideosCroned = 0;
var videosLimit=5; //how many max playlistID want ?? add here
if (videosLimit < maxResult)
{
maxResult = videosLimit;
}
YouTubeRequest request = new YouTubeRequest(settings);
do
{
totalVideosCroned += maxResult;
string uri = "http://gdata.youtube.com/feeds/api/users/";
if (!string.IsNullOrEmpty(youtubeID))
{
uri += youtubeID +"/playlists";
uri += "?key=" + DeveloperKey + "&start-index=" + start + "&max-results=" + maxResult;
//handle Playlist not found issue // use code for handling URL data
string reponse = GetHttpResponseForPlayList(uri);
start += maxResult;
var videoEntryUrl = new Uri(uri);
Feed<Video> videoFeed = request.Get<Video>(videoEntryUrl);
foreach (Video entry in videoFeed.Entries)
{
string playlistId = Regex.Replace(entry.Id, ".*:playlist:", "");
//Do cron youtube with playlist ID now
CronPlaylistYoutubeVideo(playlistId);
totalVideosCroned = videosLimit; // explicitly condition full feel to stop loop .
}
/*if (videoFeed.Entries.Count() < 50) // if need to get more playlist records, : i.e if userAccount has 100 playlist then to get all, this should be uncomment
{
totalVideosCroned = videosLimit;
}*
/* This code will get 25 playlist records without use of gdata URI
* Feed<Playlist> userPlaylists = request.GetPlaylistsFeed(channelfilter.AccountName);
foreach (Playlist playlistInfo in userPlaylists.Entries)
{
Uri playlistEntryUri = new Uri(playlistInfo.Self);
CronPlaylistYoutubeVideo(playlistEntryUri.Segments[6], channelfilter, channel, videosLimit);
totalVideosCroned = videosLimit; // explicitly stop loop.
}*/
}
else
{
totalVideosCroned = videosLimit;
}
} while (totalVideosCroned < videosLimit);
}
catch (Exception ex)
{
//handle it if need..
return;
}
试试看
{
youtuberrequestsettings=新的youtuberrequestsettings(“YoutubeLibrary”,DeveloperKey);
设置。超时=120000;
int start=1;
int maxResult=50;
int TOTAL VIDEOSCRONED=0;
var videosLimit=5;//需要多少max PLAYLIID??添加到此处
如果(videosLimit