// NOTE: An excellent example of the manifestation of ingenious engineering. // Cause of this f****n mess I need to declare a f****n lot of stuff public, although it doesn't affect anything anyway. public static async Task GetCommentsAsync( string userName, TwitchVideo.UserVideos.VideoInfo videoInfo, string outputPath, ConsoleProgressBar progressBar, BlockingCollection <Tuple <StreamWriter, TwitchComment.JsonComments> > commentsPipe, CancellationToken cancellationToken) { string?nextCursor = null; string videoID = videoInfo.VideoID; string video = $"{videoID}/comments?cursor="; StreamWriter sw = new(outputPath); do { string query = video + nextCursor; try { // NOTE: Stopwatch used to determine http response time //Stopwatch stw = new(); //stw.Start(); var jsonComments = await TwitchClient.GetJsonAsync <JsonComments>(TwitchClient.RequestType.Comment, query); //stw.Stop(); //Console.WriteLine($"Done. Time: {stw.Elapsed}"); commentsPipe.Add(new Tuple <StreamWriter, JsonComments>(sw, jsonComments)); nextCursor = jsonComments.Next; int offset = Convert.ToInt32(jsonComments.Comments[^ 1].ContentOffsetSeconds);
public static void Add(string userName, TwitchVideo.UserVideos.VideoInfo video) { // NOTE: Looks great (: // I can reduce the scope of the lock to Videos.Add(), if I add all users in advance lock (s_logsDB) { if (s_logsDB.Users.ContainsKey(userName) == false) { s_logsDB.Users.Add(userName, new JsonLogsDB.User()); s_logsDB.Users[userName].Videos = new(); } s_logsDB.Users[userName].Videos.Add(video.VideoID, new JsonLogsDB.User.Video { Duration = video.Duration, CreatedAt = video.CreatedAt }); } // NOTE: This should be in the end, but since I don't have a 'Ctrl+C' handler rn //SaveAsync().Wait(); }