From 01aac3f66e2a228508758c799059c01cdf9f3869 Mon Sep 17 00:00:00 2001 From: Benjamin Loison Date: Thu, 9 Feb 2023 01:51:22 +0100 Subject: [PATCH] Add a verification that `snippet/authorChannelId/value` isn't null when using `commentThreads` for `COMMUNITY` As it can happen cf https://www.youtube.com/channel/UCWeg2Pkate69NFdBeuRFTAw/community?lc=UgwGfjNxGuwqP8qYPPN4AaABAg&lb=UgkxYiEAo9-b1vWPasxFy13f959rrctQpZwW --- main.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/main.cpp b/main.cpp index b600ce3..795c9c2 100644 --- a/main.cpp +++ b/main.cpp @@ -357,9 +357,13 @@ void treatChannelOrVideo(unsigned short threadId, bool isChannel, string id, str items = data["items"]; for(const auto& item : items) { - json snippet = item["snippet"]["topLevelComment"]["snippet"]; - string channelId = snippet["authorChannelId"]["value"]; - addChannelToTreat(threadId, channelId); + json snippet = item["snippet"]["topLevelComment"]["snippet"], + authorChannelId = snippet["authorChannelId"]; + if(!authorChannelId["value"].is_null()) + { + string channelId = authorChannelId["value"]; + addChannelToTreat(threadId, channelId); + } string pageToken = snippet["nextPageToken"]; while(pageToken != "") {