Skip to content

Commit

Permalink
Hack/workaround for twitch not returning requested stream result count
Browse files Browse the repository at this point in the history
  • Loading branch information
laurencee committed Nov 4, 2023
1 parent 5357140 commit 45a6a27
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Livestream.Monitor/Model/ApiClients/TwitchApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,9 @@ public async Task<List<LivestreamQueryResult>> 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
Expand All @@ -323,7 +325,7 @@ public async Task<List<LivestreamQueryResult>> GetTopStreams(TopStreamQuery topS
topStreamsPaginationKeyMap[nextPageKeyLookup] = topStreams.Pagination?.Cursor;

var queryResults = new List<LivestreamQueryResult>();
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);
Expand Down

0 comments on commit 45a6a27

Please sign in to comment.