コード例 #1
0
        async Task <ICollection <ChannelVideoRow> > ChannelVideos(SeedChannel c)
        {
            var channelVids = await Yt.ChannelVideosCollection.Get(c.Id);

            return(channelVids.Vids.Select(v => new ChannelVideoRow {
                VideoId = v.VideoId,
                PublishedAt = v.PublishedAt.ToString("O"),
                ChannelId = c.Id
            }).ToList());
        }
コード例 #2
0
        async Task <ChannelRow> Channel(SeedChannel c)
        {
            var channel = await Yt.Channels.Get(c.Id);

            return(new ChannelRow {
                ChannelId = channel.ChannelId,
                Title = channel.ChannelTitle,
                SubCount = (long)(channel.Latest.Stats.SubCount ?? 0),
                ViewCount = (long)(channel.Latest.Stats.ViewCount ?? 0),
                LR = c.LR,
                Type = c.Type,
                Thumbnail = channel.Latest.Thumbnails.Medium.Url,
                UpdatedAt = channel.Latest.Stats.Updated.ToString("O")
            });
        }
コード例 #3
0
        async Task <ChannelRow> Channel(SeedChannel c)
        {
            var channel = await Yt.Channels.Get(c.Id);

            if (channel == null)
            {
                Log.Error("Unable to find seed channel {Channel}", c.Title);
                return(null);
            }
            return(new ChannelRow {
                ChannelId = channel.ChannelId,
                Title = channel.ChannelTitle,
                SubCount = (long)(channel.Latest?.Stats?.SubCount ?? 0),
                ViewCount = (long)(channel.Latest?.Stats?.ViewCount ?? 0),
                LR = c.LR,
                Type = c.Type,
                Thumbnail = channel.Latest?.Thumbnails?.Medium?.Url,
                UpdatedAt = channel.Latest?.Stats?.Updated.ToString("O")
            });
        }
コード例 #4
0
        public async Task <(ChannelStored channel, ICollection <VideoStored> videos)> UpdateChannel(SeedChannel seed)
        {
            Log.Information("Updating {Channel} with new data", seed.Title);
            var channel = await Yt.GetAndUpdateChannel(seed.Id);

            var log = Log.ForContext("Channel", channel.Latest.Title);

            async Task <(VideoStored video, RecommendedVideoStored recommended)> UpdateVideo(ChannelVideoListItem fromV)
            {
                var video = await Yt.GetAndUpdateVideo(fromV.VideoId);

                if (video == null)
                {
                    return(null, null);
                }
                var allRecommended = await Yt.GetAndUpdateRecommendedVideos(fromV);

                return(video, allRecommended);
            }

            var channelVideos = await Yt.GetAndUpdateChannelVideos(channel.Latest);

            var updateResults = await channelVideos.Vids.BlockTransform(UpdateVideo, Cfg.Parallel, null,
                                                                        p => log.Verbose("{Channel} {Videos}/{Total} channel video's visited. {Speed}",
                                                                                         channel.ChannelTitle, p.Results.Count, channelVideos.Vids.Count, p.NewItems.Count.Speed("videos", p.Elapsed).Humanize()));

            updateResults = updateResults.Where(r => r.video != null).ToList();
            log.Information("Completed {Channel} update", channel.ChannelTitle, updateResults.Count);

            return(channel, updateResults.Select(r => r.video).ToList());
        }