public static async Task <List <UserVideos> > GetVideosByUserIDsAsync(List <TwitchUser.UserInfo> users, int?firstVideos) { List <UserVideos> usersVideos = new(users.Count); int amountOfVideosForUser = firstVideos ?? 20; foreach (var user in users) { List <UserVideos.VideoInfo> videos = new(); int videosLeft = amountOfVideosForUser; int first = Math.Min(videosLeft, 100); string userQ = $"user_id={user.UserID}"; string afterQ = string.Empty; string?cursor; do { string firstQ = $"&first={first}"; string query = $"{userQ}{firstQ}{afterQ}"; var jsonVideos = await TwitchClient.GetJsonAsync <JsonVideosResponse>(TwitchClient.RequestType.Video, query); GetVideos(videos, jsonVideos.Videos); videosLeft -= jsonVideos.Videos.Length; first = Math.Min(videosLeft, 100); cursor = jsonVideos.Pagination.Cursor; afterQ = $"&after={cursor}"; } while (cursor != null && first > 0); videos.Sort((b, a) => a.DurationSeconds.CompareTo(b.DurationSeconds)); usersVideos.Add(new UserVideos(user.DisplayName, videos)); } //usersVideos.Sort((b, a) => a.DurationSeconds.CompareTo(b.DurationSeconds)); return(usersVideos); }
private static async Task <string> GetNewOAuthTokenAsync() { var jsonAppOAuthToken = await TwitchClient.GetJsonAsync <JsonAppOAuthTokenResponse>(TwitchClient.RequestType.OAuthGetNew); return(jsonAppOAuthToken !.OAuthToken); }
private static async Task <bool> ValidateTokenAsync() { var jsonAppOAuthTokenValidate = await TwitchClient.GetJsonAsync <JsonAppOAuthTokenValidate>(TwitchClient.RequestType.OAuthValidate); return(jsonAppOAuthTokenValidate is not null); }