private async Task CheckProcessingVideosAsync(VideoService videoService, FairplaytubeDatabaseContext fairplaytubeDatabaseContext, CancellationToken stoppingToken) { this.Logger?.LogInformation("Checking processing videos"); var processingInDB = await videoService.GetDatabaseProcessingVideosIdsAsync(stoppingToken); string message = $"{processingInDB.Length} videos marked as processing In DB"; this.Logger?.LogInformation(message); if (processingInDB.Length > 0) { this.Logger?.LogInformation("Retrieving videos status in Azure Video Indexer"); var videosIndex = await videoService.GetVideoIndexerStatusAsync(processingInDB, stoppingToken); if (videosIndex.results.Length > 0) { var indexCompleteVideos = videosIndex.results.Where(p => p.state == Common.Global.Enums.VideoIndexStatus.Processed.ToString()); if (indexCompleteVideos.Any()) { var indexCompleteVideosIds = indexCompleteVideos.Select(p => p.id).ToArray(); await videoService.AddVideoIndexTransactionsAsync(indexCompleteVideosIds, stoppingToken); var videosCompleted = fairplaytubeDatabaseContext.VideoInfo.Where(video => indexCompleteVideosIds.Contains(video.VideoId)); foreach (var video in videosCompleted) { await videoService.MarkVideoAsProcessedAsync(video, stoppingToken); } } } } }