#11: Add --youtube-operational-api-instance-url parameter and use exit(EXIT_{SUCCESS, FAILURE}) instead of exit({0, 1})

This commit is contained in:
Benjamin Loison 2023-01-15 00:49:32 +01:00
parent f6c11b54f3
commit 270c48da02
Signed by: Benjamin_Loison
SSH Key Fingerprint: SHA256:BtnEgYTlHdOg1u+RmYcDE0mnfz1rhv5dSbQ2gyxW8B8

View File

@ -48,7 +48,8 @@ unsigned short THREADS_NUMBER = 1;
string CHANNELS_DIRECTORY = "channels/",
CHANNELS_FILE_PATH = "channels.txt",
KEYS_FILE_PATH = "keys.txt",
apiKey = ""; // Will firstly be filled with `KEYS_FILE_PATH` first line.
apiKey = "", // Will firstly be filled with `KEYS_FILE_PATH` first line.
YOUTUBE_OPERATIONAL_API_INSTANCE_URL = "http://localhost/YouTube-operational-API"; // Can be "https://yt.lemnoslife.com" for instance.
bool USE_YT_LEMNOSLIFE_COM_NO_KEY_SERVICE = false;
int main(int argc, char *argv[])
@ -66,13 +67,26 @@ int main(int argc, char *argv[])
}
else if(argvStr == "-h" || argvStr == "--help")
{
MAIN_PRINT("Usage: " << argv[0] << " [--help/-h] [--no-keys] [--threads=N]")
exit(0);
MAIN_PRINT("Usage: " << argv[0] << " [--help/-h] [--no-keys] [--threads=N] [--youtube-operational-api-instance-url URL]")
exit(EXIT_SUCCESS);
}
else if(argvStr == "--youtube-operational-api-instance-url")
{
if(argvIndex < argc - 1)
{
YOUTUBE_OPERATIONAL_API_INSTANCE_URL = string(argv[argvIndex + 1]);
argvIndex++;
}
else
{
MAIN_PRINT("YouTube operational API instance URL missing!")
exit(EXIT_FAILURE);
}
}
else
{
MAIN_PRINT("Unrecognized parameter " << argvStr)
exit(1);
exit(EXIT_FAILURE);
}
}
@ -253,7 +267,7 @@ void treatChannelOrVideo(unsigned short threadId, bool isChannel, string id, str
if(data.contains("error"))
{
PRINT(threadId, "Not listing comments on videos, as `playlistItems` hasn't found the `uploads` playlist!")
exit(1);
exit(EXIT_FAILURE);
}
json items = data["items"];
for(const auto& item : items)
@ -282,7 +296,7 @@ void treatChannelOrVideo(unsigned short threadId, bool isChannel, string id, str
else //if(videoCount >= 20000)
{
PRINT(threadId, "The videos count of the channel exceeds the supported 20,000 limit!")
exit(1);
exit(EXIT_FAILURE);
}
}
}
@ -404,7 +418,7 @@ json getJson(unsigned short threadId, string url, string directoryPath, getJsonB
catch (json::parse_error& ex)
{
PRINT(threadId, "Parse error for " << finalUrl << ", as got: " << content << " !")
exit(1);
exit(EXIT_FAILURE);
}
if(data.contains("error"))