This是一个Youtube频道:
我只是获得频道的播放列表但是" / UC-9-kyTW8ZkZNDHQJ6FgpwQ / videos"我不知道怎么弄它?
这是我尝试过的:
List<ViewModel.YoutubeVideo> arrays = new List<ViewModel.YoutubeVideo>();
var searchListRequest = youtubeService.Playlists.List("snippet");
searchListRequest.ChannelId = channelid;
searchListRequest.MaxResults = 50;
//Call the search.list method to retrieve results...
var searchListResponse = await searchListRequest.ExecuteAsync();
foreach (var searchResult in searchListResponse.Items)
{
product = new ViewModel.YoutubeVideo();
product.id = searchResult.Id;
product.Name = searchResult.Snippet.Title;
product.Thumb100Uri = searchResult.Snippet.Thumbnails.Default.Url;
product.NextPageToken = searchListResponse.NextPageToken;
product.PreviousPageToken = searchListResponse.PrevPageToken;
arrays.Add(product);
答案 0 :(得分:0)
如果您想获得与频道中每个播放列表相关联的所有视频,您可以使用以下内容:
var playlistRequest = youtubeService.Playlists.List("id");
playlistRequest.ChannelId = "UC-9-kyTW8ZkZNDHQJ6FgpwQ";
playlistRequest.MaxResults = 50;
var playlistResponse = await playlistRequest.ExecuteAsync();
获取频道中的所有播放列表。然后:
foreach (var playlist in playlistResponse.Items)
{
var playlistItemRequest = youtubeService.PlaylistItems.List("snippet");
playlistItemRequest.PlaylistId = playlist.Id;
playlistItemRequest.MaxResults = 50;
var videos = await playlistItemRequest.ExecuteAsync();
foreach (var video in videos.Items)
{
Console.WriteLine(video.Snippet.Title);
}
}
获取每个播放列表中的所有视频。
对于您指定的频道,有很多播放列表,每个播放列表都包含大量视频,因此您需要对其进行修改,以便每次都使用页面标记来获取超过50个播放列表和视频。