Skip to content

Commit

Permalink
Fix chat/video download crash due to VOD chapter response containing …
Browse files Browse the repository at this point in the history
…a null object
  • Loading branch information
ScrubN committed Dec 19, 2023
1 parent e384cd6 commit 139d0cc
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion TwitchDownloaderCore/TwitchHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,13 @@ public static async Task<GqlVideoChapterResponse> 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<GqlVideoChapterResponse>();

var chapterResponse = await response.Content.ReadFromJsonAsync<GqlVideoChapterResponse>();
chapterResponse.data.video.moments ??= new VideoMomentConnection
{
edges = new List<VideoMomentEdge>()
};
return chapterResponse;
}

public static async Task<GqlVideoChapterResponse> GetOrGenerateVideoChapters(int videoId, VideoInfo videoInfo)
Expand Down

0 comments on commit 139d0cc

Please sign in to comment.