From ce3f2adbadcc5968e756c6813314da88d113aaac Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 1 Mar 2021 14:10:15 +0100 Subject: [PATCH] fix info funktion --- src/programManager.cpp | 115 ++++++++++++++++++++++------------------- 1 file changed, 63 insertions(+), 52 deletions(-) diff --git a/src/programManager.cpp b/src/programManager.cpp index 006e0d3..1cea0ac 100644 --- a/src/programManager.cpp +++ b/src/programManager.cpp @@ -1172,66 +1172,77 @@ int ProgramManager::infoModus(Settings *settings) int ProgramManager::newsModus(Settings *settings) { - size_t pos = 0; - PAGE page; - std::string html = pageManager.getServerRequest("https://" + page.url +"/neue-episoden").html; - if(html == "-1") { - if(settings->debugMode) - std::cerr << ">>> Debug In " << __FUNCTION__ << ": getServerRequest function failed." << std::endl; - return 1; + if(settings->pages.size() < 1) { + std::cout << " => Error Keine Internet Seiten vorhanden." << std::endl; + return -12; } - if( (pos = html.find("
")) == std::string::npos ) { - std::cout << " => Error: Konnte Position von '
'' nicht finden" <
")) == std::string::npos ) { - std::cout << " => Error: Konnte Position von '
' nicht finden" <pages ) { + std::cout << ((settings->colorless) ? "" : "\033[93m") << "Auf '" << page.url << "'..." << ((settings->colorless) ? "" : "\033[0m") << std::endl; - html = replace(html, "\n", ""); - html = replace(html, "class=\"row\"", "\n"); - - std::stringstream strstream(html + "\n"); - html.clear(); - std::string line; - while (std::getline(strstream, line).good()) { - - size_t pos = line.find(""); - size_t pos2 = line.find(""); - if(pos == std::string::npos) { - std::cout << " => Error: Konnte Position von '' nicht finden" < Error: Konnte Position von '' nicht finden" <debugMode) + std::cerr << ">>> Debug In " << __FUNCTION__ << ": getServerRequest function failed." << std::endl; + return 1; } - std::string name = line.substr(pos + 8, pos2 - pos - 8); - if( (pos = line.find("blue2\">")) == std::string::npos) { - std::cout << " => Error: Konnte Position von 'blue2\">' nicht finden" <", pos)) == std::string::npos) { - std::cout << " => Error: Konnte Position von '' nicht finden" <")) == std::string::npos ) { + std::cout << " => Error: Konnte Position von '
'' nicht finden" <
")) == std::string::npos ) { + std::cout << " => Error: Konnte Position von '
' nicht finden" <"); + size_t pos2 = line.find(""); + if(pos == std::string::npos) { + std::cout << " => Error: Konnte Position von '' nicht finden" < Error: Konnte Position von '' nicht finden" <")) == std::string::npos) { + std::cout << " => Error: Konnte Position von 'blue2\">' nicht finden" <", pos)) == std::string::npos) { + std::cout << " => Error: Konnte Position von '' nicht finden" <")) == std::string::npos) { + std::cout << " => Error: Konnte Position von 'Right\">' nicht finden" <", pos)) == std::string::npos) { + std::cout << " => Error: Konnte Position von '' nicht finden" < " << ((settings->colorless) ? "" : "\033[97m") << date << ((settings->colorless) ? "" : "\033[0m") << ": " + << ((settings->colorless) ? "" : "\033[96m") << name << ((settings->colorless) ? "" : "\033[0m") << ": " + << ((settings->colorless) ? "" : "\033[92m") << id << ((settings->colorless) ? "" : "\033[0m") << std::endl; } - std::string id = replace( line.substr(pos + 7, pos2 - pos - 7), " ", ""); - if( (pos = line.find("Right\">")) == std::string::npos) { - std::cout << " => Error: Konnte Position von 'Right\">' nicht finden" <", pos)) == std::string::npos) { - std::cout << " => Error: Konnte Position von '' nicht finden" < " << ((settings->colorless) ? "" : "\033[97m") << date << ((settings->colorless) ? "" : "\033[0m") << ": " - << ((settings->colorless) ? "" : "\033[96m") << name << ((settings->colorless) ? "" : "\033[0m") << ": " - << ((settings->colorless) ? "" : "\033[92m") << id << ((settings->colorless) ? "" : "\033[0m") << std::endl; + std::cout << std::endl; } return 0;