#11: Treat COMMUNITY
post comments to discover channels
This commit is contained in:
parent
46ef8146f8
commit
548a797ee8
60
main.cpp
60
main.cpp
@ -344,6 +344,66 @@ void treatChannelOrVideo(unsigned short threadId, bool isChannel, string id, str
|
||||
}
|
||||
breakChannelsTreatment:
|
||||
;
|
||||
// `COMMUNITY`
|
||||
pageToken = "";
|
||||
while(true)
|
||||
{
|
||||
json data = getJson(threadId, "channels?part=community&id=" + id + (pageToken == "" ? "" : "&pageToken=" + pageToken), false, id);
|
||||
data = data["items"][0];
|
||||
json posts = data["community"];
|
||||
for(const auto& post : posts)
|
||||
{
|
||||
string postId = post["id"];
|
||||
json data = getJson(threadId, "community?part=snippet&id=" + postId + "&order=time", false, id);
|
||||
string pageToken = data["items"][0]["snippet"]["comments"]["nextPageToken"];
|
||||
while(pageToken != "")
|
||||
{
|
||||
json data = getJson(threadId, "commentThreads?part=snippet,replies&pageToken=" + pageToken, false, id),
|
||||
items = data["items"];
|
||||
for(const auto& item : items)
|
||||
{
|
||||
json snippet = item["snippet"]["topLevelComment"]["snippet"];
|
||||
string channelId = snippet["authorChannelId"]["value"];
|
||||
addChannelToTreat(threadId, channelId);
|
||||
string pageToken = snippet["nextPageToken"];
|
||||
while(pageToken != "")
|
||||
{
|
||||
json data = getJson(threadId, "commentThreads?part=snippet,replies&pageToken=" + pageToken, false, id),
|
||||
items = data["items"];
|
||||
for(const auto& item : items)
|
||||
{
|
||||
string channelId = item["snippet"]["authorChannelId"]["value"];
|
||||
addChannelToTreat(threadId, channelId);
|
||||
}
|
||||
if(data.contains("nextPageToken"))
|
||||
{
|
||||
pageToken = data["nextPageToken"];
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(data.contains("nextPageToken"))
|
||||
{
|
||||
pageToken = data["nextPageToken"];
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(data.contains("nextPageToken"))
|
||||
{
|
||||
pageToken = data["nextPageToken"];
|
||||
}
|
||||
if(pageToken == "")
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
// `PLAYLISTS`
|
||||
pageToken = "";
|
||||
while(true)
|
||||
|
Loading…
Reference in New Issue
Block a user