diff --git a/Livestream.Monitor/Model/ApiClients/TwitchApiClient.cs b/Livestream.Monitor/Model/ApiClients/TwitchApiClient.cs index cb4e558..d981e31 100644 --- a/Livestream.Monitor/Model/ApiClients/TwitchApiClient.cs +++ b/Livestream.Monitor/Model/ApiClients/TwitchApiClient.cs @@ -301,7 +301,9 @@ public async Task> GetTopStreams(TopStreamQuery topS topStreamsPaginationKeyMap.TryGetValue(topStreamQuery, out var paginationKey); var query = new GetStreamsQuery() { - First = topStreamQuery.Take, + // twitch sometimes returns less streams than we ask for some unknown reason + // ask for a few more in the query to try avoid pagination issues + First = topStreamQuery.Take + 5, Pagination = new CursorPagination() { After = paginationKey @@ -323,7 +325,7 @@ public async Task> GetTopStreams(TopStreamQuery topS topStreamsPaginationKeyMap[nextPageKeyLookup] = topStreams.Pagination?.Cursor; var queryResults = new List(); - foreach (var stream in topStreams.Streams) + foreach (var stream in topStreams.Streams.Take(topStreamQuery.Take)) { var channelIdentifier = new ChannelIdentifier(this, stream.UserId) { DisplayName = stream.UserName }; var queryResult = new LivestreamQueryResult(channelIdentifier);