Fix #37: Use a number of channels seen (possibly repeated) instead of YouTube Data API v3 Comment(Thread): resource

This commit is contained in:
Benjamin Loison 2023-02-12 16:31:27 +01:00
parent 54fe40e588
commit 454503271e
Signed by: Benjamin_Loison
SSH Key Fingerprint: SHA256:BtnEgYTlHdOg1u+RmYcDE0mnfz1rhv5dSbQ2gyxW8B8

View File

@ -47,8 +47,8 @@ set<string> channelsAlreadyTreated;
map<unsigned int, string> channelsToTreat;
map<string, unsigned int> channelsToTreatRev;
vector<string> keys;
unsigned int commentsPerSecondCount = 0;
map<unsigned short, unsigned int> commentsCountThreads,
unsigned int channelsPerSecondCount = 0;
map<unsigned short, unsigned int> 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<string> parts, string delimiter)