Пример #1
0
    private async Task <List <Video> > GetExistingVideosAsync()
    {
        HttpResponse <DataPaged <Video> > allVideosResponse;
        var videos = new List <Video>();

        var pageNumber = 1;

        do
        {
            var getAllRequest = new GetAllVideosRequest(ServiceConstants.ME, pageNumber);
            allVideosResponse = await _getAllVideosService.ExecuteAsync(getAllRequest);

            if (allVideosResponse != null && allVideosResponse.Data != null)
            {
                videos.AddRange(allVideosResponse.Data.Data);
            }
            pageNumber++;
        } while (allVideosResponse != null && allVideosResponse.Data != null);

        var videoSize = System.Text.Json.JsonSerializer.Serialize(videos).Length;

        _logger.LogInformation($"Vimeo existing videos size: {videoSize.ToString("N")}");

        return(videos);
    }
Пример #2
0
    public async Task ReturnsAllVideosTest()
    {
        var request  = new GetAllVideosRequest("me");
        var response = await _getAllVideosService
                       .ExecuteAsync(request);

        response.Code.ShouldBe(System.Net.HttpStatusCode.OK);
        response.Data.Data.Count.ShouldBeGreaterThan(0);
    }
Пример #3
0
    private async Task <List <Video> > GetExistingVideosAsync()
    {
        HttpResponse <DataPaged <Video> > allVideosResponse;
        var videos = new List <Video>();

        var pageNumber = 1;

        do
        {
            var getAllRequest = new GetAllVideosRequest(ServiceConstants.ME, pageNumber);
            allVideosResponse = await _getAllVideosService.ExecuteAsync(getAllRequest);

            if (allVideosResponse != null && allVideosResponse.Data != null)
            {
                videos.AddRange(allVideosResponse.Data.Data);
            }
            pageNumber++;
        } while (allVideosResponse != null && allVideosResponse.Data != null);

        return(videos);
    }
Пример #4
0
    private async Task deleteAllVimeoVideosAsync()
    {
        HttpResponse <DataPaged <Video> > allVideos;
        var videosToDelete = new List <Video>();
        var pageNumber     = 1;

        do
        {
            var getAllRequest = new GetAllVideosRequest(ServiceConstants.ME, pageNumber);
            allVideos = await _getAllVideosService.ExecuteAsync(getAllRequest);

            if (allVideos != null && allVideos.Data != null)
            {
                videosToDelete.AddRange(allVideos.Data.Data);
            }
            pageNumber++;
        } while (allVideos != null && allVideos.Data != null);

        foreach (var video in videosToDelete)
        {
            await _deleteVideoService.ExecuteAsync(video.Id);
        }
    }
Пример #5
0
    public async Task DeleteVideosNotExistOnVimeoFromVimeo(AppendOnlyStringList?messages)
    {
        var request        = new GetAllVideosRequest("me");
        var videosResponse = await _getAllVideosService.ExecuteAsync(request);

        if (videosResponse?.Data?.Data == null)
        {
            return;
        }

        var videos = videosResponse.Data.Data;

        foreach (var video in videos)
        {
            try
            {
                if (video is { IsPlayable: false })
                {
                    await _deleteVideoService.ExecuteAsync(video.Id);

                    messages?.Append($"Video {video.Id} deleted from vimeo as it does not exist on vimeo.");
                }
            }