diff --git a/TwitchDownloaderCore/TwitchHelper.cs b/TwitchDownloaderCore/TwitchHelper.cs index ac63d99f..e5bb1612 100644 --- a/TwitchDownloaderCore/TwitchHelper.cs +++ b/TwitchDownloaderCore/TwitchHelper.cs @@ -1014,10 +1014,14 @@ public static async Task GetVideoChapters(int videoId) response.EnsureSuccessStatusCode(); var chapterResponse = await response.Content.ReadFromJsonAsync(); - chapterResponse.data.video.moments ??= new VideoMomentConnection + chapterResponse.data.video.moments ??= new VideoMomentConnection { edges = new List() }; + + // When downloading VODs of currently-airing streams, the last chapter lacks a duration + if (chapterResponse.data.video.moments.edges.LastOrDefault() is { } lastEdge && lastEdge.node.durationMilliseconds is 0) { - edges = new List() - }; + lastEdge.node.durationMilliseconds = lastEdge.node.video.lengthSeconds * 1000 - lastEdge.node.positionMilliseconds; + } + return chapterResponse; }