From 4133faad41dd461588e8a435f88564cf7534c428 Mon Sep 17 00:00:00 2001 From: Benjamin Loison Date: Sat, 21 Jan 2023 02:24:42 +0100 Subject: [PATCH] #11: Update channel `CHANNELS` tab treatment following YouTube-operational-API/issues/121 closure --- main.cpp | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/main.cpp b/main.cpp index c36d312..bc8996d 100644 --- a/main.cpp +++ b/main.cpp @@ -315,21 +315,35 @@ void treatChannelOrVideo(unsigned short threadId, bool isChannel, string id, str items = data["items"]; for(const auto& item : items) { - for(const auto& channel : item["channels"]["channels"]) + json channelSections = item["channelSections"]; + for(const auto& channelSection : channelSections) { - PRINT(threadId, channel) - addChannelToTreat(threadId, channel["channelId"]); + for(const auto& sectionChannel : channelSection["sectionChannels"]) + { + string channelId = sectionChannel["channelId"]; + addChannelToTreat(threadId, channelId); + } + } + if(channelSections.size() == 1) + { + json channelSection = channelSections[0]; + if(!channelSection["nextPageToken"].is_null()) + { + pageToken = channelSection["nextPageToken"]; + } + else + { + goto breakChannelsTreatment; + } + } + else + { + goto breakChannelsTreatment; } } - if(!data["nextPageToken"].is_null()) - { - pageToken = data["nextPageToken"]; - } - else - { - break; - } } +breakChannelsTreatment: + ; // `PLAYLISTS` pageToken = ""; while(true)