From 37afa24186694febe291d1e9f63185c04adde826 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 28 Feb 2021 23:00:11 +0100 Subject: [PATCH] fix default funktion, but account login for other page works --- src/pageManager.cpp | 26 +++---- src/pageManager.h | 14 +++- src/parameterManager.cpp | 4 +- src/programManager.cpp | 142 +++++++++++++++++++++++++++------------ src/programManager.h | 9 +-- 5 files changed, 132 insertions(+), 63 deletions(-) diff --git a/src/pageManager.cpp b/src/pageManager.cpp index 4cdcff0..11bd34f 100644 --- a/src/pageManager.cpp +++ b/src/pageManager.cpp @@ -258,12 +258,12 @@ int PageManager::downLoadToFile(std::string filePath, std::string url) return (failed) ? 10 : 0; } -int PageManager::login(Account account) +int PageManager::login(PAGE page, Account account) { if(debugMode) std::cout << " > Melde mit neuem Account an: Email: " << account.Email << " Passowort: " << account.Password << std::endl; - auto reply = getServerRequest("https://serienstream.sx/login", false, std::string("email=" + account.Email + "&password=" + account.Password), true ); + auto reply = getServerRequest("https://" + page.url + "/login", false, std::string("email=" + account.Email + "&password=" + account.Password), true ); std::string html = reply.html; if(html == "" ) @@ -290,43 +290,45 @@ std::string PageManager::getUrlAfterRedirect(std::string Url) return getServerRequest(Url, true, "", false, true).url; } -std::string PageManager::checkName(std::vector pages, std::string Name) +checkNameRply PageManager::checkName(std::vector pages, std::string Name) { int count = 0; std::string name = replace(Name, " ", "-"); std::string pagesonExist; + PAGE Page("", ""); //für jede Seite - for ( const auto &page : pages ) { + for ( const auto &p : pages ) { - std::string html = getServerRequest("https://" + page.url +"/serie/stream/" + name).html; + std::string html = getServerRequest("https://" + p.url +"/serie/stream/" + 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 "-1"; + return checkNameRply("", PAGE("", ""), checkNameRply::NEEDHELP); } else if (html == "-1" || html == "") { - return "-2"; + return checkNameRply("", PAGE("", ""), checkNameRply::FAILED); } else { count ++; - pagesonExist += page.url + " "; + pagesonExist += p.url + " "; + Page = p; } } // if( count == 1 ) { std::cout << "\33[2K\r > Name: " << name << std::endl; - return name; + return checkNameRply(name, Page, checkNameRply::SUCCESS);; } else if ( count > 1) { std::cout << "\33[2K\r => Die Serie existiert auf mehreren Seiten " << pagesonExist << ": '" << name << "'" << std::endl; - return "-1"; + return checkNameRply("", PAGE("", ""), checkNameRply::NEEDHELP);; } else { std::cout << "\33[2K\r => Die gewünschte Serie wurde nicht gefunden oder ist im Moment deaktiviert: '" << Name << "'" << std::endl; - return "-1"; + return checkNameRply("", PAGE("", ""), checkNameRply::NEEDHELP);; } } @@ -528,7 +530,7 @@ int PageManager::writeToFile(std::vector paths, std::string text) if(paths.size() == 0) return 0; std::ofstream of; - for(auto path : paths) { + for(const auto &path : paths) { of.open(path, std::ios::out | std::ios::app); if(!of.is_open()) { perror((" => Error: Konnte Output: '" + path + "' Datei nicht öffnen").c_str()); diff --git a/src/pageManager.h b/src/pageManager.h index d6e82b8..0024e13 100644 --- a/src/pageManager.h +++ b/src/pageManager.h @@ -19,6 +19,15 @@ struct Reply { std::string html, url; }; +struct checkNameRply { + std::string name; + PAGE pageInUse; + enum STATUS { SUCCESS, FAILED, NEEDHELP } status; + + checkNameRply(const std::string &name, const PAGE &p, const checkNameRply::STATUS &s ) + : name(name), pageInUse(p), status(s) {} +}; + class PageManager { @@ -35,9 +44,9 @@ public: Reply getServerRequest(std::string Url, bool useCookies = false, std::string data = "", bool generateCookieFile = false, bool UrlAfterRedirectOnlyNeeded = false); int downLoadToFile(std::string filePath, std::string url); - int login(Account account); + int login(PAGE page, Account account); std::string getUrlAfterRedirect(std::string Url); - std::string checkName(std::vector pages, std::string Name); + checkNameRply checkName(std::vector pages, std::string Name); std::string getLinks(std::string HTML); std::string chooseHosterLink(std::string HosterList, std::string Hoster_with_Highst_Priority_at_First, std::string languages_with_highst_priority_at_first, bool withWarnMsg); std::string getLinkAfterHosterBasedOperation(std::string url); @@ -52,7 +61,6 @@ public: int writeToFile(std::vector paths, std::string text); - const std::string UrlPraefix = "https://serienstream.sx/serie/stream/"; std::string sock5Proxy; private: std::string cookieFilePath; diff --git a/src/parameterManager.cpp b/src/parameterManager.cpp index 1a066ff..73fc06a 100644 --- a/src/parameterManager.cpp +++ b/src/parameterManager.cpp @@ -360,7 +360,7 @@ int unterOption_help(Settings &settings) << " -> Mit diesem Programm kann man die Download-Urls" << std::endl << " oder Informationen von Serien bekommen." << std::endl << " -> Mit diesem Programm kann man Redirect-Links von" << std::endl - << " serienstream.sx umwandeln." << std::endl + << " serienstream.sx und anicloud.io umwandeln." << std::endl << std::endl; std::cout << "Unteroptionen:" << std::endl @@ -376,7 +376,7 @@ int unterOption_help(Settings &settings) << "\t\"search\"\tModus um Serien zu suchen." << std::endl << "\t\"info\"\t\tModus um Infos einer Serien zu bekommen." << std::endl << "\t\"clean\"\t\tModus um Cookie-Files zu löschen." << std::endl - << "\t\"news\"\t\tModus um neusten 75 Folgen auf serienstream.sx zu sehen." << std::endl + << "\t\"news\"\t\tModus um neusten 75 Folgen zu sehen." << std::endl << "\t\"log\"\t\tModus um Log Datei zu sehen / leeren." << std::endl << std::endl; diff --git a/src/programManager.cpp b/src/programManager.cpp index e34a8d2..077c649 100644 --- a/src/programManager.cpp +++ b/src/programManager.cpp @@ -54,7 +54,7 @@ void * threadFunction(void * data) { myThreadData->exitState=0; - Reply tmp_reply = myThreadData->pageManager->getServerRequest(myThreadData->pageManager->UrlPraefix + myThreadData->nameInUrl + Reply tmp_reply = myThreadData->pageManager->getServerRequest( "https://" + myThreadData->page.url + myThreadData->page.UrlDir + myThreadData->nameInUrl + "/staffel-" + std::to_string(myThreadData->staffel) + "/episode-" + std::to_string(myThreadData->folge)); if(tmp_reply.html == "-1") { if(myThreadData->settings->debugMode) @@ -65,7 +65,7 @@ void * threadFunction(void * data) { std::string Link = myThreadData->pageManager->chooseHosterLink(allLinks, myThreadData->settings->genaueHoster, myThreadData->settings->languages, myThreadData->settings->debugMode); if(myThreadData->settings->debugMode) - std::cout << " > Thread " << myThreadData->id << allLinks << std::endl << ( (Link == "") ? "" : " -> Link: 'https://serienstream.sx") << Link << ( (Link == "") ? "" : "'\n" ); + std::cout << " > Thread " << myThreadData->id << allLinks << std::endl << ( (Link == "") ? "" : " -> Link: 'https://" + myThreadData->page.url) << Link << ( (Link == "") ? "" : "'\n" ); @@ -111,17 +111,17 @@ void * threadFunction(void * data) { } for (int i = 1; i <= 3; ++i) { - std::string newUrl = myThreadData->pageManager->getUrlAfterRedirect("https://serienstream.sx" + Link); + std::string newUrl = myThreadData->pageManager->getUrlAfterRedirect("https://" + myThreadData->page.url + Link); if (newUrl == "-1") { if(myThreadData->settings->debugMode) std::cerr << " => Debug: In Thread: "<< myThreadData->id << ": getUrlAfterRedirect Function failed: returned -1." << std::endl; return myThreadData->setState(16); // Get redirect link after getUrlAfterRedirect function - } else if(newUrl.find("/serienstream.sx/redirect/") != std::string::npos ) { + } else if(newUrl.find("/" + myThreadData->page.url + "/redirect/") != std::string::npos ) { if(myThreadData->settings->debugMode) std::cout << " > Thread " << myThreadData->id << "Warnung: Redirect Link nach umwandlung (Capcha?) --> Neuer Account" << std::endl; - if(myThreadData->pageManager->login(myThreadData->accountManager->getNextAccount()) != 0) { + if(myThreadData->pageManager->login(myThreadData->page, myThreadData->accountManager->getNextAccount()) != 0) { if(myThreadData->settings->debugMode) std::cerr << " => Debug: In Thread: "<< myThreadData->id << ": login Function failed." << std::endl; return myThreadData->setState(17); @@ -151,7 +151,7 @@ void * threadFunction(void * data) { } //error at 3 time - myThreadData->returnValue = " => " + replace(folgenID, "E", " E") + ( (folgenID == "") ? "" : ": " ) + red + "https://serienstream.sx" + Link + clearColor; + myThreadData->returnValue = " => " + replace(folgenID, "E", " E") + ( (folgenID == "") ? "" : ": " ) + red + "https://" + myThreadData->page.url + Link + clearColor; if(myThreadData->settings->outputFilePaths.size() != 0) if(myThreadData->pageManager->writeToFile(myThreadData->settings->outputFilePaths, replace(folgenID, "E", " E") + ( (folgenID == "") ? "" : ": " ) + Link) != 0) { if(myThreadData->settings->debugMode) @@ -183,9 +183,11 @@ int ProgramManager::waitForThreads() return 0; } -int ProgramManager::sucheNach_1_Serien(Settings *settings, PageManager &pageManager, std::string &newName) +int ProgramManager::sucheNach_1_Serien(Settings *settings, PageManager &pageManager, checkNameRply &newNameAndPage) { std::string finds; + std::string gewollteSeitenUrl; + //Führe unterfunction zum suchen von Serien aus, aber ohne suche auszugeben und speichere datein in variable if(searchModus(settings, &finds, true) != 0) { if(settings->debugMode) @@ -207,16 +209,30 @@ int ProgramManager::sucheNach_1_Serien(Settings *settings, PageManager &pageMana std::string line; std::cout << "\nWähle eine der folgenden Serien, oder nur [Enter] um Forgang abzubrechen." << std::endl; + std::string lastPage = ""; for (unsigned i = 1; std::getline(myStrStream, line).good() ; ++i) { if(line.find_last_of("|") == std::string::npos) { std::cout << " => Error: Invalid Line: " << line << std::endl; return -21; } - std::cout << i << ": " << line.substr(line.find_last_of("|") + 1) << ( (line[0] != '|') ? " ( " + line.substr(0, line.find("|")) + " )" : "" ) << std::endl; + + std::string pageUrl = line.substr( line.find_last_of('|') + 1); + //gib neue Internet seite aus, wenn sie noch nicht ausgegeben wurde + if( lastPage != pageUrl) { + std::cout << "\n-> Auf '" << pageUrl << "':" << std::endl; + lastPage = pageUrl; + } + line.erase(line.find_last_of('|')); + + if(line.find_last_of("|") == std::string::npos) { + std::cout << " => Error: Invalid Line: " << line << std::endl; + return -21; + } + std::cout << "[" << i << "]: " << line.substr(line.find_last_of("|") + 1) << ( (line[0] != '|') ? " ( " + line.substr(0, line.find("|")) + " )" : "" ) << std::endl; } //Lass Benutzer Zeile auswählen: - std::cout << "Zeile: " << std::flush; + std::cout << "\nNummer: " << std::flush; std::string input; std::getline(std::cin, input); @@ -239,11 +255,17 @@ int ProgramManager::sucheNach_1_Serien(Settings *settings, PageManager &pageMana // Wenn die Zeile gleich der ausgewählten ist: } else if(static_cast(i) == atoi(input.c_str()) ) { + //entferne und speichere PageUrl; + gewollteSeitenUrl = line.substr(line.find_last_of('|') + 1); + line.erase(line.find_last_of('|')); + //Speichere den Namen der Serie und setzte hasName auf true und brich schleife ab if ( (finds = line.substr( line.find("|/") + 2, // beginn: nach dem |/ line.find("|", line.find("|/") + 2) // Bis zu dem | ab dem ende von |/ - line.find("|/") -2) ) == "" ) { // wegen nicht bi sondern länge, suptrahiere Pos 1 std::cout << " => Error: Konnte den Namen aus der zurückgegebenen Zeile nicht extrahieren. In ausWahlVariante" << std::endl; + + if(settings->debugMode) std::cerr << ">>> Debug In " << __FUNCTION__ << ": Return value from searchModus.subStr(pos(/)-> next |, after /) is ''." << std::endl; return 48; @@ -260,6 +282,9 @@ int ProgramManager::sucheNach_1_Serien(Settings *settings, PageManager &pageMana //Wenn nur 1 Serie gefunden wurde: } else { + //entferne und speichere PageUrl; + gewollteSeitenUrl = finds.substr(finds.find_last_of('|') + 1); + finds.erase(finds.find_last_of('|')); //Frag den User ob das die Richtige Serie ist: std::cout << " -> Ist das deine gewünschte Serie: '" @@ -286,19 +311,43 @@ int ProgramManager::sucheNach_1_Serien(Settings *settings, PageManager &pageMana } } + std::cout << "NAME: " << finds << std::endl; + + + //suche Seite aus sucheregbnis in settings... + bool found = false; + for ( const auto & page : settings->pages ) { + if( page.name_id == gewollteSeitenUrl || page.url == gewollteSeitenUrl) { + newNameAndPage.pageInUse = page; + found = true; + } + } + if( !found ) { + std::cout << " => Error: Konnte '" << gewollteSeitenUrl << "' nicht als Valide Seite erkennen!" << std::endl; + if(settings->debugMode) + std::cerr << ">>> Debug In " << __FUNCTION__ << ":failed to search url in pagesList from setings object" << std::endl; + return 45; + } + //Überprüfe ob es die serie gibt wenn ja speicher ihn in newname und beende Function -//<>/newName = pageManager.checkName(finds); - if(newName == "-2") + //test jetzt nicht mehr alle seiten, sondern die die ausgewählt wurde!!!!! + std::vector pages; + pages.push_back( newNameAndPage.pageInUse ); + + auto ret = pageManager.checkName( pages /*settings->pages dann glaub ich immer fehler, wenn serie auf 2 seiten excistiert*/, finds); + if(ret.status == ret.FAILED) return 23; - else if( newName == "-1" ) { + else if( ret.status == ret.NEEDHELP ) { std::cout << " => Error: Konnte die von der Suche vorgeschlagene Serie nicht finden." << std::endl; if(settings->debugMode) std::cerr << ">>> Debug In " << __FUNCTION__ << ": Extracted Name from searchModus is invalid." << std::endl; return 47; } else { + //speichere neuen Namen in übergebenen ref var + newNameAndPage.name = ret.name; if(settings->debugMode) - std::cerr << ">>> Debug In " << __FUNCTION__ << ": Use new SerienName: '" << newName << "'." << std::endl; + std::cerr << ">>> Debug In " << __FUNCTION__ << ": Use new SerienName: '" << ret.name << "'." << std::endl; return 0; } } @@ -394,22 +443,27 @@ int ProgramManager::defaultModus(Settings *settings) //Führe Function aus, die überprüft ob die serie existiert - std::string nameInUrl =pageManager.checkName(settings->pages, settings->name); - if(nameInUrl == "-2") + auto retVal = pageManager.checkName(settings->pages, settings->name); + + if(retVal.status == retVal.FAILED) return 67; - else if(nameInUrl == "-1") { + else if(retVal.status == retVal.NEEDHELP) { //Wenn nicht, dann fühe noch eine Suche nach ähnlichen durch && Wenn nur 1ne dacnn frag ob es diese ist. int res = 0; - if( ( res = sucheNach_1_Serien(settings, pageManager, nameInUrl) ) != 0) { + if( ( res = sucheNach_1_Serien(settings, pageManager, retVal) ) != 0) { if(settings->debugMode) std::cerr << ">>> Debug In " << __FUNCTION__ << ": sucheNach_1_Serien failed or found more options." << std::endl; return (res == -10101) ? 0 : 202; } } + std::string nameInUrl = retVal.name; + PAGE page = retVal.pageInUse; + + /* Wenn multihtreading seaktiviert ist, normal login sonst bereite threads vor if(settings->maxThreads == 0) { - // melde bei serienstream.sx an und speicher cookies. + // melde bei seriens tream.sx an und speicher cookies. if (pageManager.login(accountManager.getNextAccount()) != 0) //---------------------------------------- return 29; }*/ @@ -427,7 +481,7 @@ int ProgramManager::defaultModus(Settings *settings) //pm->setProxy(settings->proxy_ip, settings->proxy_port); //pm->setCookieFilePath(settings->cookieFilePath + std::to_string( i )); - ThreadData * newThreadData = new ThreadData(i, 0, nameInUrl, -1, settings, &accountManager, pm); + ThreadData * newThreadData = new ThreadData(i, 0, nameInUrl, -1, settings, &accountManager, pm, page); threadList.push_back(newThreadData); } } @@ -442,7 +496,7 @@ int ProgramManager::defaultModus(Settings *settings) //Finde die anzahl der staffel heraus: //download html von der startpage einer serie - Reply tmp_reply = pageManager.getServerRequest(pageManager.UrlPraefix + nameInUrl); + Reply tmp_reply = pageManager.getServerRequest("https://" + page.url + page.UrlDir + nameInUrl); if(tmp_reply.html == "-1" || tmp_reply.html == "") { std::cerr << " => Error: Konnte Seitenquelltext nicht herunterladen." << std::endl; return 32; @@ -474,7 +528,7 @@ int ProgramManager::defaultModus(Settings *settings) } //Find out number of all episodes - if( (tmp_reply = pageManager.getServerRequest(pageManager.UrlPraefix + nameInUrl + "/staffel-" + std::to_string(staffel))).html == "-1") { + if( (tmp_reply = pageManager.getServerRequest("https://" + page.url + page.UrlDir + nameInUrl + "/staffel-" + std::to_string(staffel))).html == "-1") { if(settings->debugMode) std::cerr << ">>> Debug In " << __FUNCTION__ << ": getServerRequest failed when download season page." << std::endl; return 40; @@ -551,7 +605,7 @@ int ProgramManager::defaultModus(Settings *settings) // Default Mode } else { - tmp_reply =pageManager.getServerRequest(pageManager.UrlPraefix + nameInUrl + "/staffel-" + std::to_string(staffel) + "/episode-" + std::to_string(folge)); + tmp_reply =pageManager.getServerRequest( "https://" + page.url + page.UrlDir + nameInUrl + "/staffel-" + std::to_string(staffel) + "/episode-" + std::to_string(folge)); if(tmp_reply.html == "-1") { if(settings->debugMode) std::cerr << ">>> Debug In " << __FUNCTION__ << ": getServerRequest failed when download episoden page." << std::endl; @@ -572,7 +626,7 @@ int ProgramManager::defaultModus(Settings *settings) } else line.erase(0, pos); line.erase(line.find("\"")); - if(convertLink(line, &accountManager, settings, staffel, folge, allLinks) != 0) { + if(convertLink(page, line, &accountManager, settings, staffel, folge, allLinks) != 0) { if(settings->debugMode) std::cerr << ">>> Debug In " << __FUNCTION__ << ": convertLink failed." << std::endl; return 51; @@ -587,8 +641,8 @@ int ProgramManager::defaultModus(Settings *settings) std::string Link = pageManager.chooseHosterLink(allLinks, settings->genaueHoster, settings->languages, settings->debugMode); if(settings->debugMode) - std::cout << allLinks << std::endl << ( (Link == "") ? "" : " -> Link: 'https://serienstream.sx") << Link << ( (Link == "") ? "" : "'\n" ); - if(convertLink(Link, &accountManager, settings, staffel, folge, allLinks) != 0) { + std::cout << allLinks << std::endl << ( (Link == "") ? "" : " -> Link: 'https://" + page.url) << Link << ( (Link == "") ? "" : "'\n" ); + if(convertLink(page, Link, &accountManager, settings, staffel, folge, allLinks) != 0) { if(settings->debugMode) std::cerr << ">>> Debug In " << __FUNCTION__ << ": convert Link failed." << std::endl; return 51; @@ -635,7 +689,7 @@ int ProgramManager::directLinkModus(Settings *settings) std::cout << " => Error: Invalid Redirect Link: '" << line << "'" << std::endl; continue; - } else if(convertLink(line.erase(0, line.find("/redirect/") ), &accountManager, settings) != 0) { + } else if(convertLink(PAGE("", ""), line.erase(0, line.find("/redirect/") ), &accountManager, settings) != 0) { if(settings->debugMode) std::cerr << ">>> Debug In " << __FUNCTION__ << ": convert Link failed." << std::endl; return 78; @@ -797,18 +851,21 @@ int ProgramManager::infoModus(Settings *settings) } //Führe Function aus, die überprüft ob die serie existiert - std::string nameInUrl;//<>/ = pageManager.checkName(settings->name); - if(nameInUrl == "-2") + auto retV = pageManager.checkName(settings->pages, settings->name); + if(retV.status == retV.FAILED) return 145; - else if(nameInUrl == "-1") { + else if(retV.status == retV.NEEDHELP) { //Wenn nicht, dann fühe noch eine Suche nach ähnlichen durch. int res = 0; - if( ( res = sucheNach_1_Serien(settings, pageManager, nameInUrl) ) != 0) { + if( ( res = sucheNach_1_Serien(settings, pageManager, retV) ) != 0) { if(settings->debugMode) std::cerr << ">>> Debug In " << __FUNCTION__ << ": sucheNach_1_Serien function failed." << std::endl; return (res = -10101) ? 0 : 28; } } + std::string nameInUrl = retV.name; + PAGE page = retV.pageInUse; + //write Name to file if(pageManager.writeToFile(settings->outputFilePaths, "\n\nSerie: " + settings->name + " (" + nameInUrl + ")") != 0) @@ -820,7 +877,7 @@ int ProgramManager::infoModus(Settings *settings) //Finde Anzahl der Staffel heraus: - Reply tmp_reply = pageManager.getServerRequest(pageManager.UrlPraefix + nameInUrl); + Reply tmp_reply = pageManager.getServerRequest( "https://" + page.url + page.UrlDir + nameInUrl); if(tmp_reply.html == "-1") { if(settings->debugMode) std::cerr << ">>> Debug In " << __FUNCTION__ << ": getServerRequest function failed: at homepage." << std::endl; @@ -844,7 +901,7 @@ int ProgramManager::infoModus(Settings *settings) //Um namen der Folge für jede Staffel zu bekommen for (int staffel = 1; staffel <= maxStaffel; ++staffel) { - Reply tmpReply = pageManager.getServerRequest(pageManager.UrlPraefix + nameInUrl + "/staffel-" + std::to_string(staffel)); + Reply tmpReply = pageManager.getServerRequest( "https://" + page.url + page.UrlDir + nameInUrl + "/staffel-" + std::to_string(staffel)); if(tmpReply.html == "-1") { if(settings->debugMode) std::cerr << ">>> Debug In " << __FUNCTION__ << ": getServerRequest function failed: at season page." << std::endl; @@ -1073,7 +1130,8 @@ int ProgramManager::infoModus(Settings *settings) int ProgramManager::newsModus(Settings *settings) { size_t pos = 0; - std::string html = pageManager.getServerRequest("https://serienstream.sx/neue-episoden").html; + 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; @@ -1602,7 +1660,7 @@ int ProgramManager::listDir(std::string &list,std::string path, int maxDepth, bo return 0; } -int ProgramManager::convertLink(std::string redirectLink, AccountManager * accountManager, +int ProgramManager::convertLink(PAGE page, std::string redirectLink, AccountManager * accountManager, Settings * settings, int Staffel, int Folge, std::string allLinks) { std::string folgenID = std::string((Staffel == -1 || Folge == -1 ) ? "" : "S" + std::string( (Staffel < 10) ? "0" : "" ) + std::to_string(Staffel) @@ -1635,7 +1693,7 @@ int ProgramManager::convertLink(std::string redirectLink, AccountManager * accou } for (int i = 1; i <= 3; ++i) { - std::string newUrl = pageManager.getUrlAfterRedirect("https://serienstream.sx" + redirectLink); + std::string newUrl = pageManager.getUrlAfterRedirect("https://" + page.url + redirectLink); //wenn function fehl schlug beende das Programm if (newUrl == "-1") { if(settings->debugMode) @@ -1643,22 +1701,22 @@ int ProgramManager::convertLink(std::string redirectLink, AccountManager * accou return 102; // wenn nach der Umwandlung immern och ein redirect vorhanden ist, also wenn z.B.: account gewechselt werden muss - } else if(newUrl.find("/serienstream.sx/redirect/") != std::string::npos ) { + } else if(newUrl.find("/" + page.url + "/redirect/") != std::string::npos ) { if(settings->debugMode) std::cout << "Warnung: Redirect Link nach umwandlung (Capcha?) --> Neuer Account" << std::endl; - if(pageManager.login(accountManager->getNextAccount()) != 0) { + if(pageManager.login(page, accountManager->getNextAccount()) != 0) { if(settings->debugMode) std::cerr << ">>> Debug In " << __FUNCTION__ << ": login f() failed." << std::endl; return -1; } continue; - //wenn nach der Umwandlung https://serienstream.sx/ vorhanden ist, die ist wenn der Link Ungültig war: - } else if (newUrl == "https://serienstream.sx/") { - std::cout << " => " << red << replace(folgenID, "E", " E") << ( (folgenID == "") ? "" : ": " ) << "Ungültige Url: 'https://serienstream.sx" << redirectLink << "'" + //wenn nach der Umwandlung https://seriens tream.sx/ vorhanden ist, die ist wenn der Link Ungültig war: + } else if (newUrl == "https://" + page.url + "/") { + std::cout << " => " << red << replace(folgenID, "E", " E") << ( (folgenID == "") ? "" : ": " ) << "Ungültige Url: 'https://" + page.url << redirectLink << "'" << ((settings->colorless) ? "" : "\033[0m") << std::endl; if(settings->outputFilePaths.size() != 0) - if(pageManager.writeToFile(settings->outputFilePaths, replace(folgenID, "E", " E") + ( (folgenID == "") ? "" : ": " ) + "Ungültige Url: https://serienstream.sx" + redirectLink) != 0) { + if(pageManager.writeToFile(settings->outputFilePaths, replace(folgenID, "E", " E") + ( (folgenID == "") ? "" : ": " ) + "Ungültige Url: https://" + page.url + redirectLink) != 0) { if(settings->debugMode) std::cerr << ">>> Debug In " << __FUNCTION__ << ": writeToFile f() failed." << std::endl; return 108; @@ -1684,7 +1742,7 @@ int ProgramManager::convertLink(std::string redirectLink, AccountManager * accou } //nach 3temn Versuch gib error aus: - std::cout << " => " << replace(folgenID, "E", " E") << ( (folgenID == "") ? "" : ": " ) << red << "https://serienstream.sx" << redirectLink << ((settings->colorless) ? "" : "\033[0m") << std::endl; + std::cout << " => " << replace(folgenID, "E", " E") << ( (folgenID == "") ? "" : ": " ) << red << "https://" + page.url << redirectLink << ((settings->colorless) ? "" : "\033[0m") << std::endl; if(settings->outputFilePaths.size() != 0) { if(pageManager.writeToFile(settings->outputFilePaths, replace(folgenID, "E", " E") + ( (folgenID == "") ? "" : ": " ) + redirectLink) != 0) { if(settings->debugMode) diff --git a/src/programManager.h b/src/programManager.h index 985abcb..64f4072 100644 --- a/src/programManager.h +++ b/src/programManager.h @@ -11,10 +11,11 @@ struct ThreadData { - ThreadData(unsigned id, pthread_t init, std::string nameinUrl,int exitStateInit, Settings * settings, AccountManager * accountMg, PageManager * pM) - : id(id), thread(init), nameInUrl(nameinUrl), exitState(exitStateInit), settings(settings), accountManager(accountMg), pageManager(pM) {} + ThreadData(unsigned id, pthread_t init, std::string nameinUrl,int exitStateInit, Settings * settings, AccountManager * accountMg, PageManager * pM, PAGE p) + : id(id), page(p), thread(init), nameInUrl(nameinUrl), exitState(exitStateInit), settings(settings), accountManager(accountMg), pageManager(pM) {} unsigned id; + PAGE page; pthread_t thread; std::string nameInUrl, returnValue; int staffel, folge, exitState; @@ -54,10 +55,10 @@ private: std::vector threadList; unsigned nextThread; - int convertLink(std::string redirectLink, AccountManager *accountManager, Settings * settings, int Staffel = -1, int Folge = -1, std::string allLinks = "NOT_EMPTY"); + int convertLink(PAGE page, std::string redirectLink, AccountManager *accountManager, Settings * settings, int Staffel = -1, int Folge = -1, std::string allLinks = "NOT_EMPTY"); int searchModus_update(Settings * settings); int waitForThreads(); - int sucheNach_1_Serien(Settings *settings, PageManager &pageManager, std::string &newName); + int sucheNach_1_Serien(Settings *settings, PageManager &pageManager, checkNameRply &newNameAndPage); int checkLastUpdate(Settings * settings, ssize_t *days);