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)
|
int ProgramManager::newsModus(Settings *settings)
|
||||||
{
|
{
|
||||||
size_t pos = 0;
|
if(settings->pages.size() < 1) {
|
||||||
PAGE page;
|
std::cout << " => Error Keine Internet Seiten vorhanden." << std::endl;
|
||||||
std::string html = pageManager.getServerRequest("https://" + page.url +"/neue-episoden").html;
|
return -12;
|
||||||
if(html == "-1") {
|
|
||||||
if(settings->debugMode)
|
|
||||||
std::cerr << ">>> Debug In " << __FUNCTION__ << ": getServerRequest function failed." << std::endl;
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( (pos = html.find("<div class=\"row\">")) == std::string::npos ) {
|
for( const auto &page : settings->pages ) {
|
||||||
std::cout << " => Error: Konnte Position von '<div class=\"row\">'' nicht finden" <<std::endl;
|
std::cout << ((settings->colorless) ? "" : "\033[93m") << "Auf '" << page.url << "'..." << ((settings->colorless) ? "" : "\033[0m") << 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", "");
|
size_t pos = 0;
|
||||||
html = replace(html, "class=\"row\"", "\n");
|
std::string html = pageManager.getServerRequest("https://" + page.url +"/neue-episoden").html;
|
||||||
|
if(html == "-1") {
|
||||||
std::stringstream strstream(html + "\n");
|
if(settings->debugMode)
|
||||||
html.clear();
|
std::cerr << ">>> Debug In " << __FUNCTION__ << ": getServerRequest function failed." << std::endl;
|
||||||
std::string line;
|
return 1;
|
||||||
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) {
|
if( (pos = html.find("<div class=\"row\">")) == std::string::npos ) {
|
||||||
std::cout << " => Error: Konnte Position von 'blue2\">' nicht finden" <<std::endl;
|
std::cout << " => Error: Konnte Position von '<div class=\"row\">'' nicht finden" <<std::endl;
|
||||||
return 5;
|
return 2;
|
||||||
} else if( (pos2 = line.find("</span>", pos)) == std::string::npos) {
|
} else
|
||||||
std::cout << " => Error: Konnte Position von '' nicht finden" <<std::endl;
|
html.erase(0, pos + 17);
|
||||||
return 6;
|
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") << ": "
|
std::cout << std::endl;
|
||||||
<< ((settings->colorless) ? "" : "\033[96m") << name << ((settings->colorless) ? "" : "\033[0m") << ": "
|
|
||||||
<< ((settings->colorless) ? "" : "\033[92m") << id << ((settings->colorless) ? "" : "\033[0m") << std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user