public async Task DownloadAsync() { JArray taskLinks = await TwitchHelper.GetClipLinks(downloadOptions.Id); string downloadUrl = ""; foreach (var quality in taskLinks[0]["data"]["clip"]["videoQualities"]) { if (quality["quality"].ToString() == downloadOptions.Quality) { downloadUrl = quality["sourceURL"].ToString(); } } if (downloadUrl == "") { downloadUrl = taskLinks[0]["data"]["clip"]["videoQualities"].First["sourceURL"].ToString(); } using (WebClient client = new WebClient()) await client.DownloadFileTaskAsync(downloadUrl, downloadOptions.Filename); }
public async Task DownloadAsync() { JArray taskLinks = await TwitchHelper.GetClipLinks(downloadOptions.Id); string downloadUrl = ""; foreach (var quality in taskLinks[0]["data"]["clip"]["videoQualities"]) { if (quality["quality"].ToString() == downloadOptions.Quality) { downloadUrl = quality["sourceURL"].ToString(); } } if (downloadUrl == "") { downloadUrl = taskLinks[0]["data"]["clip"]["videoQualities"].First["sourceURL"].ToString(); } downloadUrl += "?sig=" + taskLinks[0]["data"]["clip"]["playbackAccessToken"]["signature"] + "&token=" + HttpUtility.UrlEncode(taskLinks[0]["data"]["clip"]["playbackAccessToken"]["value"].ToString()); using (WebClient client = new WebClient()) await client.DownloadFileTaskAsync(downloadUrl, downloadOptions.Filename); }