diff --git a/TwitchDownloaderWPF/InfoHelper.cs b/TwitchDownloaderWPF/InfoHelper.cs index e008d78b..7c192407 100644 --- a/TwitchDownloaderWPF/InfoHelper.cs +++ b/TwitchDownloaderWPF/InfoHelper.cs @@ -84,15 +84,14 @@ public static async Task GetClipInfoChat(object clipId) } } - public static async Task GetClipLinks(object clipId) + public static async Task GetClipLinks(object clipId) { using (WebClient client = new WebClient()) { client.Encoding = Encoding.UTF8; client.Headers.Add("Client-ID", "kimne78kx3ncx6brgo4mv6wki5h1ko"); - //API is deprecated - hopefully keeps working for a while. Can genereate full url from thumbnail but fails ocasionally https://discuss.dev.twitch.tv/t/clips-api-does-not-expose-video-url/15763/2 - string response = await client.DownloadStringTaskAsync(String.Format("https://clips.twitch.tv/api/v2/clips/{0}/status", clipId)); - JObject result = JObject.Parse(response); + string response = await client.UploadStringTaskAsync(new Uri("https://gql.twitch.tv/gql", UriKind.Absolute), "[{\"operationName\":\"VideoAccessToken_Clip\",\"variables\":{\"slug\":\"" + clipId + "\"},\"extensions\":{\"persistedQuery\":{\"version\":1,\"sha256Hash\":\"9bfcc0177bffc730bd5a5a89005869d2773480cf1738c592143b5173634b7d15\"}}}]"); + JArray result = JArray.Parse(response); return result; } } diff --git a/TwitchDownloaderWPF/PageClipDownload.xaml.cs b/TwitchDownloaderWPF/PageClipDownload.xaml.cs index d93c88e2..04a16263 100644 --- a/TwitchDownloaderWPF/PageClipDownload.xaml.cs +++ b/TwitchDownloaderWPF/PageClipDownload.xaml.cs @@ -46,7 +46,7 @@ private async void btnGetInfo_Click(object sender, RoutedEventArgs e) btnGetInfo.IsEnabled = false; comboQuality.Items.Clear(); Task taskInfo = InfoHelper.GetClipInfo(clipId); - Task taskLinks = InfoHelper.GetClipLinks(clipId); + Task taskLinks = InfoHelper.GetClipLinks(clipId); await Task.WhenAll(taskInfo, taskLinks); JToken clipData = taskInfo.Result["data"][0]; @@ -59,9 +59,9 @@ private async void btnGetInfo_Click(object sender, RoutedEventArgs e) textCreatedAt.Text = clipData["created_at"].ToString(); textTitle.Text = clipData["title"].ToString(); - foreach (var quality in taskLinks.Result["quality_options"]) + foreach (var quality in taskLinks.Result[0]["data"]["clip"]["videoQualities"]) { - comboQuality.Items.Add(new TwitchClip(quality["quality"].ToString(), quality["frame_rate"].ToString(), quality["source"].ToString())); + comboQuality.Items.Add(new TwitchClip(quality["quality"].ToString(), quality["frameRate"].ToString(), quality["sourceURL"].ToString())); } comboQuality.SelectedIndex = 0; @@ -72,7 +72,7 @@ private async void btnGetInfo_Click(object sender, RoutedEventArgs e) catch (Exception ex) { MessageBox.Show("Unable to get Clip information. Please double check Clip Slug and try again", "Unable to get info", MessageBoxButton.OK, MessageBoxImage.Error); - AppendLog("ERROR: " + ex.Message); + AppendLog("ERROR: " + ex); btnGetInfo.IsEnabled = true; } } diff --git a/TwitchDownloaderWPF/TwitchDownloader.csproj b/TwitchDownloaderWPF/TwitchDownloader.csproj index 01402aa3..b0cbef73 100644 --- a/TwitchDownloaderWPF/TwitchDownloader.csproj +++ b/TwitchDownloaderWPF/TwitchDownloader.csproj @@ -16,6 +16,21 @@ true + false + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + true AnyCPU @@ -251,17 +266,28 @@ + + + False + Microsoft .NET Framework 4.7.2 %28x86 and x64%29 + true + + + False + .NET Framework 3.5 SP1 + false + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + - RMDIR "$(TargetDir)de/" /S /Q @@ -278,4 +304,5 @@ RMDIR "$(TargetDir)pt-BR/" /S /Q RMDIR "$(TargetDir)zh-Hans/" /S /Q RMDIR "$(TargetDir)zh-Hant/" /S /Q + \ No newline at end of file