/// <summary> /// Create start conversion from video to GIF. /// </summary> /// <param name="vidUrl">Video url to convert to GIF</param> /// <returns></returns> private async ValueTask <IVidToGIF> ConvertVidToGIFInternal(string vidUrl) { var prePoll = await CreatePollVidToGIFInternal(vidUrl); if (string.IsNullOrEmpty(prePoll.Ticket)) { throw new ImgurException("Create poll request failed."); } string url = $"poll"; for (int i = 0; i < 1200; i++) /* Loop for 2 min polling waiting 100 ms per iteration*/ { using (var request = VidToGifRequestBuilder.PollVidToGIFRequest(url, prePoll.Ticket)) { var returnGif = await SendRequestAsync <VidToGIF>(request).ConfigureAwait(false); if (returnGif?.ProgressOverall == 1 && !string.IsNullOrEmpty(returnGif?.Id)) { return(returnGif); } } Thread.Sleep(100); } return(null); }
private async ValueTask <IVidToGIFPoll> CreatePollVidToGIFInternal(string vidUrl) { string url = "upload"; using (var request = VidToGifRequestBuilder.ConvertVidToGIFRequest(url, vidUrl)) { var returnPoll = await SendRequestAsync <VidToGIFPoll>(request).ConfigureAwait(false); return(returnPoll); } }