diff --git a/main.cpp b/main.cpp index 9e9b1b9..8d2a823 100644 --- a/main.cpp +++ b/main.cpp @@ -117,13 +117,16 @@ int main(int argc, char *argv[]) for(const auto& entry : filesystem::directory_iterator(CHANNELS_DIRECTORY)) { - string fileName = entry.path().filename(), - channelId = fileName.substr(0, fileName.length() - 4); + string fileName = entry.path().filename(); + // Skip files such as `UNLISTED_VIDEOS_FILE_PATH`. + if (fileName.substr(0, 2) == "UC") { + string channelId = fileName.substr(0, fileName.length() - 4); - channelsToTreat.erase(channelsToTreatRev[channelId]); - channelsToTreatRev.erase(channelId); + channelsToTreat.erase(channelsToTreatRev[channelId]); + channelsToTreatRev.erase(channelId); - channelsAlreadyTreated.insert(channelId); + channelsAlreadyTreated.insert(channelId); + } } MAIN_PRINT(channelsToTreat.size() << " channel(s) to treat") @@ -532,7 +535,7 @@ void treatChannelOrVideo(unsigned short threadId, bool isChannel, string id, str // We verify that we don't skip any message by verifying that the first message was already treated if we already treated some messages. if(!messageIds.empty() && messageIds.find(firstMessageId) == messageIds.end()) { - EXIT_WITH_ERROR("The verification that we don't skip any message failed!") + PRINT("The verification that we don't skip any message failed! Continuing anyway...") } for(const auto& message : snippet) { @@ -751,7 +754,9 @@ json getJson(unsigned short threadId, string url, bool usingYoutubeDataApiv3, st } catch (json::parse_error& ex) { - EXIT_WITH_ERROR("Parse error for " << finalUrl << ", as got: " << content << " !") + // From the experience this sometimes happens due to empty `content` but retrying just after solves the problem. + PRINT("Parse error for " << finalUrl << ", as got: " << content << " ! Retrying...") + return getJson(threadId, url, usingYoutubeDataApiv3, channelId); } if(data.contains("error"))