From d37d5ab73e97748ebd09db265bbf00c456bf8387 Mon Sep 17 00:00:00 2001 From: Markus Date: Sat, 26 Mar 2022 00:23:20 +0100 Subject: [PATCH] fix_new_site_changes --- src/accountManager.cpp | 22 ++++++++++--- src/accountManager.h | 3 +- src/logger.cpp | 4 +-- src/logger.h | 5 ++- src/pageManager.cpp | 32 ++++++++++++------ src/pageManager.h | 4 +-- src/parameterManager.cpp | 50 +++++++++++++--------------- src/parameterManager.h | 28 +++++++++------- src/programManager.cpp | 70 +++++++++++++++++++++------------------- 9 files changed, 124 insertions(+), 94 deletions(-) diff --git a/src/accountManager.cpp b/src/accountManager.cpp index a2e6541..27c991e 100644 --- a/src/accountManager.cpp +++ b/src/accountManager.cpp @@ -1,7 +1,7 @@ #include "accountManager.h" -AccountManager::AccountManager(std::string pathToFil, std::string pathToAccountNumberFile, PAGE page) - : pathToAccountNumberFile(pathToAccountNumberFile + "_" + page.name_id), pageInUse(page) +AccountManager::AccountManager(std::string pathToFil, std::string pathToAccountNumberFile, PAGE page, const PAGE *pagesALL) + : pagesALL(pagesALL), pathToAccountNumberFile(pathToAccountNumberFile + "_" + page.name_id), pageInUse(page) { std::string pathToAccountsFile = pathToFil + "_" + page.name_id; std::ifstream ifs(pathToAccountsFile); @@ -68,7 +68,21 @@ int AccountManager::writeDefault(std::string path) ofs << "# <- Am Anfang der Zeile deaktiviert diese." << std::endl; ofs << "#Email/Passwort - Falls diese gleich sind, geht auch nur Email oder Passwort" << std::endl; - if( pageInUse.url == "serienstream.sx" || pageInUse.url == "s.to" ) { + enum pagesID { + STO, + ANICLOUD, + STOIP, + SERIENSTREAMSX, + SERIENCAM, + SERIENSTREAMTO + }; + + if( pageInUse.url == pagesALL[STO].url + || pageInUse.url == pagesALL[STOIP].url + || pageInUse.url == pagesALL[SERIENSTREAMSX].url + || pageInUse.url == pagesALL[SERIENCAM].url + || pageInUse.url == pagesALL[SERIENSTREAMTO].url) + { ofs << "EntzueckendPackenderSkorpion@oida.icu" << std::endl; ofs << "HumorvollWundervollerDelfin@spam.care/HumorvollWundervollerDelfin@spam.care" << std::endl; ofs << "ExzellentPackenderHirsch@muell.icu/ExzellentPackenderHirsch@muell.icu" << std::endl; @@ -160,7 +174,7 @@ int AccountManager::writeDefault(std::string path) ofs << "BerauschendUnglaublicherGorilla@oida.icu" << std::endl; ofs << "GenuesslichPraechtigerDachs@spam.care" << std::endl; - } else if( pageInUse.url == "anicloud.io" ) { + } else if( pageInUse.url == pagesALL[ANICLOUD].url ) { ofs << "C322334ark1954@teleworm.us/C322334ark1954@teleworm.us" << std::endl; ofs << "wemixex225@iconmle.com/wemixex225@iconmle.com" << std::endl; ofs << "Thw86757utary@teleworm.us" << std::endl; diff --git a/src/accountManager.h b/src/accountManager.h index c9f5f08..883b552 100644 --- a/src/accountManager.h +++ b/src/accountManager.h @@ -19,9 +19,10 @@ struct Account { class AccountManager { public: - AccountManager(std::string pathToFile, std::string pathToAccountNumberFile, PAGE page); + AccountManager(std::string pathToFile, std::string pathToAccountNumberFile, PAGE page, const PAGE * pagesALL); Account getNextAccount(); size_t getLastAccountNumber(); + const PAGE * pagesALL; private: std::vector accounts; diff --git a/src/logger.cpp b/src/logger.cpp index e1550aa..28d3d95 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -1,7 +1,7 @@ #include "logger.h" -Logger::Logger(std::string logFilePath) - : filePath(logFilePath) +Logger::Logger(std::string logFilePathm) + : filePath(logFilePathm) { if(openFile(filePath)) exit(234); diff --git a/src/logger.h b/src/logger.h index e078972..4dbaee5 100644 --- a/src/logger.h +++ b/src/logger.h @@ -10,11 +10,13 @@ #include // std::time, localtime ... +#include "parameterManager.h" + class Logger { public: - Logger(std::string logFilePath); + Logger(std::string logFilePathm); ~Logger(); std::string getFilePath(); std::fstream file; @@ -24,6 +26,7 @@ public: std::string getLogText(); int clearFile(); + private: std::string filePath; int writetoFile(std::string t); diff --git a/src/pageManager.cpp b/src/pageManager.cpp index 2b05ffb..8fff83c 100644 --- a/src/pageManager.cpp +++ b/src/pageManager.cpp @@ -78,8 +78,10 @@ void PageManager::get_terminal_size(int& width) { #endif // Windows/Linux } -Reply PageManager::getServerRequest(std::string Url, bool useCookies, std::string data, bool generateCookieFile, bool UrlAfterRedirectOnlyNeeded, std::string cookieFilePath) +Reply PageManager::getServerRequest(std::string protocol, std::string Url, bool useCookies, std::string data, bool generateCookieFile, bool UrlAfterRedirectOnlyNeeded, std::string cookieFilePath) { + Url = protocol + Url; // add https:// + CURL *curl; CURLcode res; std::string readBuffer; @@ -264,9 +266,13 @@ int PageManager::login(PAGE page, Account account, std::string cookieFilePath) if(debugMode) std::cout << " > Melde mit neuem Account an: Email: " << account.Email << " Passowort: " << account.Password << std::endl; - auto reply = getServerRequest("https://" + page.url + "/login", false, std::string("email=" + account.Email + "&password=" + account.Password), true, false, cookieFilePath ); + auto reply = getServerRequest( page.protocol, page.url + "/login", false, std::string("email=" + account.Email + "&password=" + account.Password), true, false, cookieFilePath ); std::string html = reply.html; + auto fs = std::vector(); + fs.push_back("/home/markus/aaaaaaaaaaaaaaaaaaaaaaaa.html"); + this->writeToFile(fs, html); + if(html == "" ) return 0; else if (html.find("Das Feld Email muss eine gültige E-Mail-Adresse enthalten.") != std::string::npos) @@ -278,6 +284,9 @@ int PageManager::login(PAGE page, Account account, std::string cookieFilePath) else if (html.find("Ein Account mit dieser E-Mail Adresse wurde nicht gefunden.") != std::string::npos) std::cout << " => Error: Login failed: Ein Account mit dieser E-Mail Adresse wurde nicht gefunden." << std::endl << " Email: '" << account.Email << "' Passwort: '" << account.Password << "'" << std::endl; + else if (html.find("Dein Internetzugang wird zensiert (DNS-Sperre)" ) != std::string::npos) + std::cout << " => Error: Login failed: Dein Internetzugang wird zensiert (DNS-Sperre) -> Verwende IP?" << std::endl + << " Email: '" << account.Email << "' Passwort: '" << account.Password << "'" << std::endl; else if(html == "-1") return -1; else @@ -286,9 +295,9 @@ int PageManager::login(PAGE page, Account account, std::string cookieFilePath) return -1; } -Reply PageManager::getUrlAfterRedirect(std::string Url, std::string cookieFilePath) +Reply PageManager::getUrlAfterRedirect( std::string p,std::string Url, std::string cookieFilePath) { - return getServerRequest(Url, true, "", false, true, cookieFilePath); + return getServerRequest(p , Url, true, "", false, true, cookieFilePath); } checkNameRply PageManager::checkName(std::vector pages, std::string Name, bool useFirstPage) @@ -309,16 +318,17 @@ checkNameRply PageManager::checkName(std::vector pages, std::string Name, //für jede Seite for ( const auto &p : pages ) { - std::string html = getServerRequest("https://" + p.url + p.UrlDir + name).html; + std::string html = getServerRequest(p.protocol, p.url + p.UrlDir + name).html; if(html.find("Die gewünschte Serie wurde nicht gefunden oder ist im Moment deaktiviert.") != std::string::npos) { continue; } else if (html.find("404 - Seite nicht gefunden") != std::string::npos) { std::cout << "\33[2K\r" <<" => Ungültiger Name: '" << Name << "'" << std::endl; - return checkNameRply("", PAGE(), checkNameRply::NOTHING_FOUND); + continue; } else if (html == "-1" || html == "") { - return checkNameRply("", PAGE(), checkNameRply::FAILED); + std::cout << "\33[2K\r" <<" => WARNUNG: Das laden der Seite : '" << p.url << "' ist fehlgeschlagen" << std::endl; + continue; } else { @@ -341,7 +351,7 @@ checkNameRply PageManager::checkName(std::vector pages, std::string Name, } else if ( count > 1) { std::cout << "\33[2K\r => Die Serie existiert auf mehreren Seiten " << name << ": '" << pagesonExist << "'" << std::endl; std::cout << "\33[2K\r Benutze die Option -f --use-first, um automatisch die 1. Seite zu verwenden!" << std::endl; - return checkNameRply("", PAGE(), checkNameRply::NOTHING_FOUND); //MULTIPLE OPTIONS FOUND!!!! + return checkNameRply("", PAGE(), checkNameRply::NOTHING_FOUND); //MULTIPLE OPTIONS FOUND!!!! same option -> führe suche funktion aus } else { std::cout << "\33[2K\r => Die gewünschte Serie wurde nicht gefunden oder ist im Moment deaktiviert: '" << Name << "'" << std::endl; return checkNameRply("", PAGE(), checkNameRply::NOTHING_FOUND); @@ -362,13 +372,15 @@ std::string PageManager::getLinks(std::string HTML) //Entferne alles nach den Links //pos = HTML.find("