From f86e5a99b94196f36a745e4fdf1ce70659192fcb Mon Sep 17 00:00:00 2001 From: Markus Date: Sat, 17 Aug 2019 16:06:33 +0200 Subject: [PATCH] rename myka and ka to myThreadData and ThreadData --- programManager.cpp | 86 +++++++++++++++++++++++----------------------- programManager.h | 6 ++-- 2 files changed, 46 insertions(+), 46 deletions(-) diff --git a/programManager.cpp b/programManager.cpp index 1b8ce9b..5d6ebb7 100644 --- a/programManager.cpp +++ b/programManager.cpp @@ -41,73 +41,73 @@ int ProgramManager::start(Settings *settings) } } -void * threadFunction(void * KA) { - ka * myka = reinterpret_cast(KA); - myka->returnValue=""; - myka->exitState=0; +void * threadFunction(void * data) { + ThreadData * myThreadData = reinterpret_cast(data); + myThreadData->returnValue=""; + myThreadData->exitState=0; - Reply tmp_reply = myka->pageManager->getServerRequest(myka->pageManager->UrlPraefix + myka->nameInUrl - + "/staffel-" + std::to_string(myka->staffel) + "/episode-" + std::to_string(myka->folge)); + Reply tmp_reply = myThreadData->pageManager->getServerRequest(myThreadData->pageManager->UrlPraefix + myThreadData->nameInUrl + + "/staffel-" + std::to_string(myThreadData->staffel) + "/episode-" + std::to_string(myThreadData->folge)); if(tmp_reply.html == "-1") - return myka->setState(10); - std::string allLinks = myka->pageManager->getLinks(tmp_reply.html); - std::string Link = myka->pageManager->chooseHosterLink(allLinks, myka->settings->genaueHoster, myka->settings->languages); + return myThreadData->setState(10); + std::string allLinks = myThreadData->pageManager->getLinks(tmp_reply.html); + std::string Link = myThreadData->pageManager->chooseHosterLink(allLinks, myThreadData->settings->genaueHoster, myThreadData->settings->languages); - if(myka->settings->debugMode) - std::cout << " > Thread " << myka->id << allLinks << std::endl << ( (Link == "") ? "" : " -> Link: 'https://s.to") << Link << ( (Link == "") ? "" : "'\n" ); + if(myThreadData->settings->debugMode) + std::cout << " > Thread " << myThreadData->id << allLinks << std::endl << ( (Link == "") ? "" : " -> Link: 'https://s.to") << Link << ( (Link == "") ? "" : "'\n" ); - std::string folgenID = std::string((myka->staffel == -1 || myka->folge == -1 ) ? "" : "S" + std::string( (myka->staffel < 10) ? "0" : "" ) + std::to_string(myka->staffel) - + "E" + std::string( (myka->folge < 10) ? "0" : "" ) + std::to_string( myka->folge ) ); - std::string green = ((myka->settings->colorless) ? "" : "\033[32m"), - red = ((myka->settings->colorless) ? "" : "\033[31m"), - orange =((myka->settings->colorless) ? "" : "\033[33m"), - blue = ((myka->settings->colorless) ? "" : "\033[34m"); + std::string folgenID = std::string((myThreadData->staffel == -1 || myThreadData->folge == -1 ) ? "" : "S" + std::string( (myThreadData->staffel < 10) ? "0" : "" ) + std::to_string(myThreadData->staffel) + + "E" + std::string( (myThreadData->folge < 10) ? "0" : "" ) + std::to_string( myThreadData->folge ) ); + std::string green = ((myThreadData->settings->colorless) ? "" : "\033[32m"), + red = ((myThreadData->settings->colorless) ? "" : "\033[31m"), + orange =((myThreadData->settings->colorless) ? "" : "\033[33m"), + blue = ((myThreadData->settings->colorless) ? "" : "\033[34m"); if(Link == "") { if(allLinks == "") { - myka->returnValue = " => " + red + "KEINEN Hoster für die Folge " + folgenID + " gefunden." + "\033[0m"; - if(myka->pageManager->writeToFile(myka->settings->outputFilePath, std::string("KEINEN Hoster für die Folge ") + folgenID + std::string(" gefunden.")) != 0) - return myka->setState(14); + myThreadData->returnValue = " => " + red + "KEINEN Hoster für die Folge " + folgenID + " gefunden." + "\033[0m"; + if(myThreadData->pageManager->writeToFile(myThreadData->settings->outputFilePath, std::string("KEINEN Hoster für die Folge ") + folgenID + std::string(" gefunden.")) != 0) + return myThreadData->setState(14); } else { - myka->returnValue = " => " + orange + "Keinen PASSENDEN Hoster für die Folge " + folgenID + " gefunden." + "\033[0m" + "\n" + myThreadData->returnValue = " => " + orange + "Keinen PASSENDEN Hoster für die Folge " + folgenID + " gefunden." + "\033[0m" + "\n" + "Alle Links:" + "\n" - + myka->pageManager->replace( myka->pageManager->replace( myka->pageManager->replace( allLinks, "data-lang-key=\"1\"", "language=\"GerDub\"" ), + + myThreadData->pageManager->replace( myThreadData->pageManager->replace( myThreadData->pageManager->replace( allLinks, "data-lang-key=\"1\"", "language=\"GerDub\"" ), "data-lang-key=\"2\"", "language=\"Eng\"" ), "data-lang-key=\"3\"", "language=\"GerSub\""); - if(myka->pageManager->writeToFile(myka->settings->outputFilePath, std::string("Keinen PASSENDEN Hoster für die Folge ") + folgenID + std::string(" gefunden.")) != 0) - return myka->setState(15); + if(myThreadData->pageManager->writeToFile(myThreadData->settings->outputFilePath, std::string("Keinen PASSENDEN Hoster für die Folge ") + folgenID + std::string(" gefunden.")) != 0) + return myThreadData->setState(15); } - return myka->setState(0); + return myThreadData->setState(0); } for (int i = 1; i <= 3; ++i) { - std::string newUrl = myka->pageManager->getUrlAfterRedirect("https://s.to" + Link); + std::string newUrl = myThreadData->pageManager->getUrlAfterRedirect("https://s.to" + Link); if (newUrl == "-1") { - return myka->setState(16); + return myThreadData->setState(16); } else if(newUrl.find("/s.to/redirect/") != std::string::npos ) { - if(myka->settings->debugMode) - std::cout << " > Thread " << myka->id << "Warnung: Redirect Link nach umwandlung (Capcha?) --> Neuer Account" << std::endl; - if(myka->pageManager->login(myka->accountManager->getNextAccount()) != 0) - return myka->setState(17); + 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) + return myThreadData->setState(17); continue; } else { - myka->returnValue = " => " + folgenID + ( (folgenID == "") ? "" : ": " ) + green + newUrl + "\033[0m"; - if(myka->settings->outputFilePath != "") - if(myka->pageManager->writeToFile(myka->settings->outputFilePath,folgenID + ( (folgenID == "") ? "" : ": " ) + newUrl) != 0) - return myka->setState(18); - return myka->setState(0); + myThreadData->returnValue = " => " + folgenID + ( (folgenID == "") ? "" : ": " ) + green + newUrl + "\033[0m"; + if(myThreadData->settings->outputFilePath != "") + if(myThreadData->pageManager->writeToFile(myThreadData->settings->outputFilePath,folgenID + ( (folgenID == "") ? "" : ": " ) + newUrl) != 0) + return myThreadData->setState(18); + return myThreadData->setState(0); } } - myka->returnValue = " => " + folgenID + ( (folgenID == "") ? "" : ": " ) + red + "https://s.to" + Link + "\033[0m"; - if(myka->settings->outputFilePath != "") - if(myka->pageManager->writeToFile(myka->settings->outputFilePath, folgenID + ( (folgenID == "") ? "" : ": " ) + Link) != 0) - return myka->setState(19); - return myka->setState(0); + myThreadData->returnValue = " => " + folgenID + ( (folgenID == "") ? "" : ": " ) + red + "https://s.to" + Link + "\033[0m"; + if(myThreadData->settings->outputFilePath != "") + if(myThreadData->pageManager->writeToFile(myThreadData->settings->outputFilePath, folgenID + ( (folgenID == "") ? "" : ": " ) + Link) != 0) + return myThreadData->setState(19); + return myThreadData->setState(0); } @@ -184,8 +184,8 @@ int ProgramManager::defaultModus(Settings *settings) //pm->setProxy(settings->proxy_ip, settings->proxy_port); //pm->setCookieFilePath(settings->cookieFilePath + std::to_string( i )); - ka * newKa = new ka(i, 0, nameInUrl, -1, settings, &accountManager, pm); - threadList.push_back(newKa); + ThreadData * newThreadData = new ThreadData(i, 0, nameInUrl, -1, settings, &accountManager, pm); + threadList.push_back(newThreadData); } } diff --git a/programManager.h b/programManager.h index 5673f86..7783d34 100644 --- a/programManager.h +++ b/programManager.h @@ -10,9 +10,9 @@ #include -struct ka +struct ThreadData { - ka(unsigned id, pthread_t init, std::string nameinUrl,int exitStateInit, Settings * settings, AccountManager * accountMg, PageManager * pM) + 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) {} unsigned id; @@ -48,7 +48,7 @@ private: int infoModus(Settings * settings); PageManager pageManager; - std::vector threadList; + 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");