public IEnumerable <VideoDto> ListVideos()
        {
            using (IServiceScope scope = serviceScopeFactory.CreateScope())
            {
                IVideoRepository videoDb     = scope.ServiceProvider.GetRequiredService <IVideoRepository>();
                YoutubeInterface ytInterface = scope.ServiceProvider.GetRequiredService <YoutubeInterface>();
                YouTubeService   ytService   = ytInterface.GetYoutubeService();

                List <VideoDto> query = videoDb.GetAll().Result.OrderBy(vd => vd.StartTime).Select(vd => new VideoDto(vd)).ToList();

                //foreach (Video v in videoDb.GetAll())
                //{
                //    VideoDto video = ytInterface.GetVideoInfo(ytService, v.VideoId).Result;
                //    if (video == null)
                //    {
                //        logger.LogWarning("{0} is not available", v.VideoId);
                //        continue;
                //    }
                //    v.VideoTitle = video.VideoTitle;
                //    v.Misc = video.Misc;
                //    videoDb.Save(v);
                //}

                ITimeStampRepository tsDb = scope.ServiceProvider.GetRequiredService <ITimeStampRepository>();
                return(query.Select(vdto =>
                {
                    vdto.TimeStamps = tsDb.Query(ts => ts.VideoId.Equals(vdto.VideoId)).Result
                                      .OrderBy(ts => ts.Time)
                                      .Select(ts => new TimeStampDto(ts));
                    return vdto;
                }));
            }
        }
 public KonluluStreamGrabHostedService(IBackgroundTaskQueue <KonluluStreamGrabStateObject> taskQueue, IServiceScopeFactory serviceScopeFactory, ILogger <KonluluStreamGrabHostedService> logger, YoutubeInterface ytInterface)
 {
     this.taskQueue           = taskQueue;
     this.serviceScopeFactory = serviceScopeFactory;
     this.logger      = logger;
     this.ytInterface = ytInterface;
 }
 internal DiscordModule(ILogger <DiscordModule> logger,
                        YoutubeInterface ytService,
                        IServiceScopeFactory serviceScopeFactory)
 {
     this.logger              = logger;
     this.ytService           = ytService;
     this.serviceScopeFactory = serviceScopeFactory;
     logger.LogInformation("Loaded default Module");
 }