Example #1
0
        public async Task <VimeoVidoeResponseDto> GetVimeoVideoStutasByIdAsync(int videoId)
        {
            var user = await GetCurrentUser();

            var video = await _videoRepository.GetVideoByIdAsync(videoId);

            if (video == null)
            {
                throw new NotFoundException("Video not found");
            }
            var getVideoUrl         = string.Format(_vimeoConfig.GetVideoUrl, video.VimeoId);
            var vidoeUploadResponse = await VimeoHelper.VideoGetAsync(_vimeoConfig.Token, getVideoUrl);

            vidoeUploadResponse.VideoId = video.Id;
            return(vidoeUploadResponse);
        }
Example #2
0
        // Synchronize database video with vimeo video
        public async Task SynchronizeVideoAsync(int videoId)
        {
            // 1. get user & video info
            var user = await GetCurrentUser();

            var video = await _videoRepository.GetVideoByIdAsync(videoId);

            if (video == null)
            {
                throw new NotFoundException("video not found");
            }
            // 2. check course status
            video.Content.Lecture.Section.Course.CourseUpdateValidate(user);
            // 3. get video duration from vimeo
            var getVideoUrl = string.Format(_vimeoConfig.GetVideoUrl, video.VimeoId);
            var vimeoVideo  = await VimeoHelper.VideoGetAsync(_vimeoConfig.Token, getVideoUrl);

            // 4. update video duration in database
            video.Update(null, vimeoVideo.Duration);
            await _videoRepository.SaveAsync();

            // 5. add videoId to vimeo
            await VimeoHelper.VideoEditPatchAsync(_vimeoConfig.Token, getVideoUrl, videoId.ToString());
        }