Ejemplo n.º 1
0
    public async Task DeleteVideosNotExistOnVimeoFromDatabase(AppendOnlyStringList?messages)
    {
        var spec   = new ArchiveVideoWithoutThumbnailSpec();
        var videos = await _repositoryArchiveVideo.ListAsync(spec);

        foreach (var video in videos)
        {
            try
            {
                var response = await _getVideoService.ExecuteAsync(video.VideoId);

                if (response?.Data != null && response.Data.IsPlayable == false)
                {
                    await _deleteVideoService.ExecuteAsync(video.VideoId);

                    messages?.Append($"Video {video.Id} deleted from vimeo as it does not exist on vimeo.");
                }
                if (response?.Data == null || response?.Data.IsPlayable == false)
                {
                    await _repositoryArchiveVideo.DeleteAsync(video);

                    messages?.Append($"Video {video.VideoId} deleted as it does not exist on vimeo.");
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, $"Error on Delete Video {video.VideoId}: {ex.Message}");
            }
        }
    }
Ejemplo n.º 2
0
    public async Task UpdateVideosThumbnail(AppendOnlyStringList?messages)
    {
        var spec   = new ArchiveVideoWithoutThumbnailSpec();
        var videos = await _repositoryArchiveVideo.ListAsync(spec);

        foreach (var video in videos)
        {
            try
            {
                var response = await _getVideoService.ExecuteAsync(video.VideoId);

                if (response?.Data == null)
                {
                    continue;
                }
                var existThumbsResponse = await _getAllAnimatedThumbnailService.ExecuteAsync(new GetAnimatedThumbnailRequest(long.Parse(video.VideoId !), null));

                if (existThumbsResponse.Data.Total <= 0)
                {
                    var getAnimatedThumbnailResult = await _createAnimatedThumbnailsService.ExecuteAsync(long.Parse(video.VideoId !));

                    if (getAnimatedThumbnailResult == null || response?.Data.IsPlayable == false)
                    {
                        continue;
                    }
                    video.AnimatedThumbnailUri = getAnimatedThumbnailResult.AnimatedThumbnailUri;
                }
                else
                {
                    video.AnimatedThumbnailUri = existThumbsResponse.Data.Data.FirstOrDefault()?.AnimatedThumbnailUri;
                }

                await _repositoryArchiveVideo.UpdateAsync(video);

                messages?.Append($"Video {video.VideoId} updated with Thumbnails.");
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, $"Error on Thumbnails for Video {video.VideoId}: {ex.Message}");
            }
        }
    }