From 454503271ebe2de356c0b53216dcf66dca36dfd2 Mon Sep 17 00:00:00 2001 From: Benjamin Loison Date: Sun, 12 Feb 2023 16:31:27 +0100 Subject: [PATCH] Fix #37: Use a number of channels seen (possibly repeated) instead of YouTube Data API v3 Comment(Thread): resource --- main.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/main.cpp b/main.cpp index 303ffb9..2841706 100644 --- a/main.cpp +++ b/main.cpp @@ -47,8 +47,8 @@ set channelsAlreadyTreated; map channelsToTreat; map channelsToTreatRev; vector keys; -unsigned int commentsPerSecondCount = 0; -map commentsCountThreads, +unsigned int channelsPerSecondCount = 0; +map channelsCountThreads, requestsPerChannelThreads; unsigned short THREADS_NUMBER = 1; // Use `string` variables instead of macros to have `string` properties, even if could use a meta-macro inlining as `string`s. @@ -137,8 +137,8 @@ int main(int argc, char *argv[]) while(true) { - MAIN_PRINT("Comments per second: " << commentsPerSecondCount) - commentsPerSecondCount = 0; + MAIN_PRINT("Channels per second: " << channelsPerSecondCount) + channelsPerSecondCount = 0; sleep(1); } @@ -168,7 +168,7 @@ void treatChannels(unsigned short threadId) PRINT("Treating channel " << channelToTreat << " (treated: " << channelsAlreadyTreated.size() << ", to treat: " << channelsToTreat.size() << ")") - commentsCountThreads[threadId] = 0; + channelsCountThreads[threadId] = 0; requestsPerChannelThreads[threadId] = 0; channelsToTreat.erase(channelsToTreatRev[channelToTreat]); @@ -197,7 +197,7 @@ void treatChannels(unsigned short threadId) deleteDirectory(channelToTreatDirectory); PRINT("Deleting directory finished.") - PRINT(commentsCountThreads[threadId] << " comments were found for this channel.") + PRINT(channelsCountThreads[threadId] << " comments were found for this channel.") } channelsAlreadyTreatedAndToTreatMutex.unlock(); @@ -613,6 +613,8 @@ void treatChannelOrVideo(unsigned short threadId, bool isChannel, string id, str // This function verifies that the given hasn't already been treated. void addChannelToTreat(unsigned short threadId, string channelId) { + channelsPerSecondCount++; + channelsCountThreads[threadId]++; channelsAlreadyTreatedAndToTreatMutex.lock(); if(channelsAlreadyTreated.find(channelId) == channelsAlreadyTreated.end() && channelsToTreatRev.find(channelId) == channelsToTreatRev.end()) { @@ -639,8 +641,6 @@ void treatComment(unsigned short threadId, json comment, string channelId) string channelId = snippet["authorChannelId"]["value"]; addChannelToTreat(threadId, channelId); } - commentsCountThreads[threadId]++; - commentsPerSecondCount++; } string join(vector parts, string delimiter)