/// <summary>The most popular in that channel. Video's do not include related data.</summary> public async Task <ICollection <ChannelVideoListItem> > VideosInChannel(ChannelData c, DateTime publishedAfter, DateTime?publishBefore = null) { var s = YtService.Search.List("snippet"); s.ChannelId = c.Id; s.PublishedAfter = publishedAfter; s.PublishedBefore = publishBefore; s.MaxResults = 50; s.Order = SearchResource.ListRequest.OrderEnum.Date; s.Type = "video"; var vids = new List <ChannelVideoListItem>(); while (true) { var res = await GetResponse(s); vids.AddRange(res.Items.Where(v => v.Snippet.PublishedAt != null).Select(v => new ChannelVideoListItem { VideoId = v.Id.VideoId, VideoTitle = v.Snippet.Title, PublishedAt = v.Snippet.PublishedAt, Updated = DateTime.UtcNow })); if (res.NextPageToken == null) { break; } s.PageToken = res.NextPageToken; } return(vids); }
public async Task <ChannelData> ChannelData(string id) { var s = YtService.Channels.List("snippet,statistics"); s.Id = id; var r = await GetResponse(s); var c = r.Items.FirstOrDefault(); if (c == null) { return(null); } var data = new ChannelData { Id = id, Title = c.Snippet.Title, Description = c.Snippet.Description, Country = c.Snippet.Country, Thumbnails = c.Snippet.Thumbnails, Stats = new ChannelStats { ViewCount = c.Statistics.ViewCount, SubCount = c.Statistics.SubscriberCount, Updated = DateTime.UtcNow }, Status = ChannelStatus.Alive }; return(data); }