public async Task GetVideoRateCountNetAsync() { var res = await YouTubeSite.GetVideoRateCountNetAsync(new List <string> { "lHgIpxQac3w", "-wA6Qj4oF2E" }).ConfigureAwait(false); Assert.IsTrue(res.Count == 2); var res1 = await YouTubeSite.GetVideoViewCountNetAsync("lHgIpxQac3w").ConfigureAwait(false); Assert.IsTrue(res[0].ViewCount == res1.ViewCount); }
public static async Task SyncChannelRatesAsync(IChannel channel) { var ids = new List <string>(); switch (channel.Site) { case SiteType.NotSet: ids = channel.ChannelItems.Select(x => x.ID).ToList(); break; case SiteType.YouTube: ids = await db.GetChannelItemsIdListDbAsync(channel.ID, 0, 0).ConfigureAwait(false); break; } IEnumerable <List <string> > chanks = ids.SplitList(); foreach (List <string> list in chanks) { List <StatisticPOCO> items = await YouTubeSite.GetVideoRateCountNetAsync(list); foreach (StatisticPOCO itemp in items.Where(itemp => itemp.Filled)) { await db.UpdateItemRateCount(itemp.VideoId, itemp); IVideoItem item = channel.ChannelItems.FirstOrDefault(x => x.ID == itemp.VideoId); if (item == null) { continue; } if (itemp.ViewCount != item.ViewCount) { item.ViewDiff = itemp.ViewCount - item.ViewCount; } item.ViewCount = itemp.ViewCount; item.LikeCount = itemp.LikeCount; item.DislikeCount = itemp.DislikeCount; item.Comments = itemp.CommentCount; channel.ChannelViewCount += item.ViewCount; channel.ChannelLikeCount += item.LikeCount; channel.ChannelDislikeCount += item.DislikeCount; channel.ChannelCommentCount += item.Comments; } } }