diff --git a/TwitchDownloaderCore/TwitchHelper.cs b/TwitchDownloaderCore/TwitchHelper.cs index 53708a33..4906c4bf 100644 --- a/TwitchDownloaderCore/TwitchHelper.cs +++ b/TwitchDownloaderCore/TwitchHelper.cs @@ -34,6 +34,7 @@ public static async Task GetVideoInfo(int videoId) }; request.Headers.Add("Client-ID", "kimne78kx3ncx6brgo4mv6wki5h1ko"); using var response = await httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead); + response.EnsureSuccessStatusCode(); return await response.Content.ReadFromJsonAsync(); } @@ -49,6 +50,7 @@ public static async Task GetVideoToken(int videoId, strin if (authToken != null && authToken != "") request.Headers.Add("Authorization", "OAuth " + authToken); using var response = await httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead); + response.EnsureSuccessStatusCode(); return await response.Content.ReadFromJsonAsync(); } @@ -74,6 +76,7 @@ public static async Task GetClipInfo(object clipId) }; request.Headers.Add("Client-ID", "kimne78kx3ncx6brgo4mv6wki5h1ko"); using var response = await httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead); + response.EnsureSuccessStatusCode(); return await response.Content.ReadFromJsonAsync(); } @@ -87,6 +90,7 @@ public static async Task> GetClipLinks(string clipId) }; request.Headers.Add("Client-ID", "kimne78kx3ncx6brgo4mv6wki5h1ko"); using var response = await httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead); + response.EnsureSuccessStatusCode(); return await response.Content.ReadFromJsonAsync>(); } @@ -100,6 +104,7 @@ public static async Task GetGqlVideos(string channelName }; request.Headers.Add("Client-ID", "kimne78kx3ncx6brgo4mv6wki5h1ko"); using var response = await httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead); + response.EnsureSuccessStatusCode(); return await response.Content.ReadFromJsonAsync(); } @@ -113,6 +118,7 @@ public static async Task GetGqlClips(string channelName, }; request.Headers.Add("Client-ID", "kimne78kx3ncx6brgo4mv6wki5h1ko"); using var response = await httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead); + response.EnsureSuccessStatusCode(); return await response.Content.ReadFromJsonAsync(); } @@ -148,6 +154,7 @@ private static async Task GetBttvEmoteData(int streamerId, List>(); //Channel might not have BTTV emotes @@ -177,6 +184,7 @@ private static async Task GetFfzEmoteData(int streamerId, List>(); //Channel might not have FFZ emotes @@ -205,6 +213,7 @@ private static async Task GetStvEmoteData(int streamerId, List(); var stvEmotes = globalEmoteObject.emotes; @@ -437,10 +446,12 @@ public static async Task> GetEmotes(List comments, st // TODO: would want to make this configurable as we do for emotes though... var globalBadgeRequest = new HttpRequestMessage(HttpMethod.Get, new Uri("https://badges.twitch.tv/v1/badges/global/display", UriKind.Absolute)); using var globalBadgeResponse = await httpClient.SendAsync(globalBadgeRequest, HttpCompletionOption.ResponseHeadersRead, cancellationToken); + globalBadgeResponse.EnsureSuccessStatusCode(); var globalBadges = await globalBadgeResponse.Content.ReadFromJsonAsync(cancellationToken: cancellationToken); var subBadgeRequest = new HttpRequestMessage(HttpMethod.Get, new Uri($"https://badges.twitch.tv/v1/badges/channels/{streamerId}/display", UriKind.Absolute)); using var subBadgeResponse = await httpClient.SendAsync(subBadgeRequest, HttpCompletionOption.ResponseHeadersRead, cancellationToken); + subBadgeResponse.EnsureSuccessStatusCode(); var subBadges = await subBadgeResponse.Content.ReadFromJsonAsync(cancellationToken: cancellationToken); List badges = new List(); @@ -643,6 +654,7 @@ public static async Task> GetBits(List comments, strin }; request.Headers.Add("Client-ID", "kimne78kx3ncx6brgo4mv6wki5h1ko"); using var cheerResponseMessage = await httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, cancellationToken); + cheerResponseMessage.EnsureSuccessStatusCode(); var cheerResponse = await cheerResponseMessage.Content.ReadFromJsonAsync(cancellationToken: cancellationToken); string bitFolder = Path.Combine(cacheFolder, "bits"); @@ -814,6 +826,7 @@ public static async Task GetUserInfo(List idList) }; request.Headers.Add("Client-ID", "kimne78kx3ncx6brgo4mv6wki5h1ko"); using var response = await httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead); + response.EnsureSuccessStatusCode(); return await response.Content.ReadFromJsonAsync(); } @@ -890,6 +903,7 @@ public static async Task GetVideoChapters(int videoId) }; request.Headers.Add("Client-ID", "kimne78kx3ncx6brgo4mv6wki5h1ko"); using var response = await httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead); + response.EnsureSuccessStatusCode(); return await response.Content.ReadFromJsonAsync(); } }