forked from markus/S_New4
fix info funktion
This commit is contained in:
parent
bb5571b20b
commit
ce3f2adbad
@ -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("<div class=\"row\">")) == std::string::npos ) {
|
||||
std::cout << " => Error: Konnte Position von '<div class=\"row\">'' nicht finden" <<std::endl;
|
||||
return 2;
|
||||
} else
|
||||
html.erase(0, pos + 17);
|
||||
if( (pos = html.find("<div class=\"cf\"></div>")) == std::string::npos ) {
|
||||
std::cout << " => Error: Konnte Position von '<div class=\"cf\"></div>' nicht finden" <<std::endl;
|
||||
return 2;
|
||||
} else
|
||||
html.erase(pos + 12);
|
||||
for( const auto &page : settings->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("<strong>");
|
||||
size_t pos2 = line.find("</strong>");
|
||||
if(pos == std::string::npos) {
|
||||
std::cout << " => Error: Konnte Position von '<strong>' nicht finden" <<std::endl;
|
||||
return 3;
|
||||
} else if(pos2 == std::string::npos) {
|
||||
std::cout << " => Error: Konnte Position von '</strong>' nicht finden" <<std::endl;
|
||||
return 4;
|
||||
size_t pos = 0;
|
||||
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;
|
||||
}
|
||||
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" <<std::endl;
|
||||
return 5;
|
||||
} else if( (pos2 = line.find("</span>", pos)) == std::string::npos) {
|
||||
std::cout << " => Error: Konnte Position von '' nicht finden" <<std::endl;
|
||||
return 6;
|
||||
if( (pos = html.find("<div class=\"row\">")) == std::string::npos ) {
|
||||
std::cout << " => Error: Konnte Position von '<div class=\"row\">'' nicht finden" <<std::endl;
|
||||
return 2;
|
||||
} else
|
||||
html.erase(0, pos + 17);
|
||||
if( (pos = html.find("<div class=\"cf\"></div>")) == std::string::npos ) {
|
||||
std::cout << " => Error: Konnte Position von '<div class=\"cf\"></div>' nicht finden" <<std::endl;
|
||||
return 2;
|
||||
} else
|
||||
html.erase(pos + 12);
|
||||
|
||||
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("<strong>");
|
||||
size_t pos2 = line.find("</strong>");
|
||||
if(pos == std::string::npos) {
|
||||
std::cout << " => Error: Konnte Position von '<strong>' nicht finden" <<std::endl;
|
||||
return 3;
|
||||
} else if(pos2 == std::string::npos) {
|
||||
std::cout << " => Error: Konnte Position von '</strong>' nicht finden" <<std::endl;
|
||||
return 4;
|
||||
}
|
||||
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" <<std::endl;
|
||||
return 5;
|
||||
} else if( (pos2 = line.find("</span>", pos)) == std::string::npos) {
|
||||
std::cout << " => Error: Konnte Position von '' nicht finden" <<std::endl;
|
||||
return 6;
|
||||
}
|
||||
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" <<std::endl;
|
||||
return 5;
|
||||
} else if( (pos2 = line.find("</span>", pos)) == std::string::npos) {
|
||||
std::cout << " => Error: Konnte Position von '</span>' nicht finden" <<std::endl;
|
||||
return 6;
|
||||
}
|
||||
std::string date = line.substr(pos + 7, pos2 - pos - 7);
|
||||
|
||||
std::cout << " > " << ((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" <<std::endl;
|
||||
return 5;
|
||||
} else if( (pos2 = line.find("</span>", pos)) == std::string::npos) {
|
||||
std::cout << " => Error: Konnte Position von '</span>' nicht finden" <<std::endl;
|
||||
return 6;
|
||||
}
|
||||
std::string date = line.substr(pos + 7, pos2 - pos - 7);
|
||||
|
||||
std::cout << " > " << ((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;
|
||||
|
Loading…
Reference in New Issue
Block a user