rename myka and ka to myThreadData and ThreadData

This commit is contained in:
Markus 2019-08-17 16:06:33 +02:00
parent 291e0d2acd
commit f86e5a99b9
2 changed files with 46 additions and 46 deletions

View File

@ -41,73 +41,73 @@ int ProgramManager::start(Settings *settings)
} }
} }


void * threadFunction(void * KA) { void * threadFunction(void * data) {
ka * myka = reinterpret_cast<struct ka*>(KA); ThreadData * myThreadData = reinterpret_cast<struct ThreadData*>(data);
myka->returnValue=""; myThreadData->returnValue="";
myka->exitState=0; myThreadData->exitState=0;




Reply tmp_reply = myka->pageManager->getServerRequest(myka->pageManager->UrlPraefix + myka->nameInUrl Reply tmp_reply = myThreadData->pageManager->getServerRequest(myThreadData->pageManager->UrlPraefix + myThreadData->nameInUrl
+ "/staffel-" + std::to_string(myka->staffel) + "/episode-" + std::to_string(myka->folge)); + "/staffel-" + std::to_string(myThreadData->staffel) + "/episode-" + std::to_string(myThreadData->folge));
if(tmp_reply.html == "-1") if(tmp_reply.html == "-1")
return myka->setState(10); return myThreadData->setState(10);
std::string allLinks = myka->pageManager->getLinks(tmp_reply.html); std::string allLinks = myThreadData->pageManager->getLinks(tmp_reply.html);
std::string Link = myka->pageManager->chooseHosterLink(allLinks, myka->settings->genaueHoster, myka->settings->languages); std::string Link = myThreadData->pageManager->chooseHosterLink(allLinks, myThreadData->settings->genaueHoster, myThreadData->settings->languages);


if(myka->settings->debugMode) if(myThreadData->settings->debugMode)
std::cout << " > Thread " << myka->id << allLinks << std::endl << ( (Link == "") ? "" : " -> Link: 'https://s.to") << Link << ( (Link == "") ? "" : "'\n" ); 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) 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( (myka->folge < 10) ? "0" : "" ) + std::to_string( myka->folge ) ); + "E" + std::string( (myThreadData->folge < 10) ? "0" : "" ) + std::to_string( myThreadData->folge ) );
std::string green = ((myka->settings->colorless) ? "" : "\033[32m"), std::string green = ((myThreadData->settings->colorless) ? "" : "\033[32m"),
red = ((myka->settings->colorless) ? "" : "\033[31m"), red = ((myThreadData->settings->colorless) ? "" : "\033[31m"),
orange =((myka->settings->colorless) ? "" : "\033[33m"), orange =((myThreadData->settings->colorless) ? "" : "\033[33m"),
blue = ((myka->settings->colorless) ? "" : "\033[34m"); blue = ((myThreadData->settings->colorless) ? "" : "\033[34m");


if(Link == "") { if(Link == "") {
if(allLinks == "") { if(allLinks == "") {
myka->returnValue = " => " + red + "KEINEN Hoster für die Folge " + folgenID + " gefunden." + "\033[0m"; myThreadData->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) if(myThreadData->pageManager->writeToFile(myThreadData->settings->outputFilePath, std::string("KEINEN Hoster für die Folge ") + folgenID + std::string(" gefunden.")) != 0)
return myka->setState(14); return myThreadData->setState(14);
} }
else { 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" + "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\""); "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) if(myThreadData->pageManager->writeToFile(myThreadData->settings->outputFilePath, std::string("Keinen PASSENDEN Hoster für die Folge ") + folgenID + std::string(" gefunden.")) != 0)
return myka->setState(15); return myThreadData->setState(15);
} }
return myka->setState(0); return myThreadData->setState(0);
} }


for (int i = 1; i <= 3; ++i) { 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") { if (newUrl == "-1") {
return myka->setState(16); return myThreadData->setState(16);
} else if(newUrl.find("/s.to/redirect/") != std::string::npos ) { } else if(newUrl.find("/s.to/redirect/") != std::string::npos ) {
if(myka->settings->debugMode) if(myThreadData->settings->debugMode)
std::cout << " > Thread " << myka->id << "Warnung: Redirect Link nach umwandlung (Capcha?) --> Neuer Account" << std::endl; std::cout << " > Thread " << myThreadData->id << "Warnung: Redirect Link nach umwandlung (Capcha?) --> Neuer Account" << std::endl;
if(myka->pageManager->login(myka->accountManager->getNextAccount()) != 0) if(myThreadData->pageManager->login(myThreadData->accountManager->getNextAccount()) != 0)
return myka->setState(17); return myThreadData->setState(17);
continue; continue;


} else { } else {
myka->returnValue = " => " + folgenID + ( (folgenID == "") ? "" : ": " ) + green + newUrl + "\033[0m"; myThreadData->returnValue = " => " + folgenID + ( (folgenID == "") ? "" : ": " ) + green + newUrl + "\033[0m";
if(myka->settings->outputFilePath != "") if(myThreadData->settings->outputFilePath != "")
if(myka->pageManager->writeToFile(myka->settings->outputFilePath,folgenID + ( (folgenID == "") ? "" : ": " ) + newUrl) != 0) if(myThreadData->pageManager->writeToFile(myThreadData->settings->outputFilePath,folgenID + ( (folgenID == "") ? "" : ": " ) + newUrl) != 0)
return myka->setState(18); return myThreadData->setState(18);
return myka->setState(0); return myThreadData->setState(0);
} }
} }
myka->returnValue = " => " + folgenID + ( (folgenID == "") ? "" : ": " ) + red + "https://s.to" + Link + "\033[0m"; myThreadData->returnValue = " => " + folgenID + ( (folgenID == "") ? "" : ": " ) + red + "https://s.to" + Link + "\033[0m";
if(myka->settings->outputFilePath != "") if(myThreadData->settings->outputFilePath != "")
if(myka->pageManager->writeToFile(myka->settings->outputFilePath, folgenID + ( (folgenID == "") ? "" : ": " ) + Link) != 0) if(myThreadData->pageManager->writeToFile(myThreadData->settings->outputFilePath, folgenID + ( (folgenID == "") ? "" : ": " ) + Link) != 0)
return myka->setState(19); return myThreadData->setState(19);
return myka->setState(0); return myThreadData->setState(0);


} }


@ -184,8 +184,8 @@ int ProgramManager::defaultModus(Settings *settings)
//pm->setProxy(settings->proxy_ip, settings->proxy_port); //pm->setProxy(settings->proxy_ip, settings->proxy_port);
//pm->setCookieFilePath(settings->cookieFilePath + std::to_string( i )); //pm->setCookieFilePath(settings->cookieFilePath + std::to_string( i ));


ka * newKa = new ka(i, 0, nameInUrl, -1, settings, &accountManager, pm); ThreadData * newThreadData = new ThreadData(i, 0, nameInUrl, -1, settings, &accountManager, pm);
threadList.push_back(newKa); threadList.push_back(newThreadData);
} }
} }



View File

@ -10,9 +10,9 @@
#include <pthread.h> #include <pthread.h>




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) {} : id(id), thread(init), nameInUrl(nameinUrl), exitState(exitStateInit), settings(settings), accountManager(accountMg), pageManager(pM) {}


unsigned id; unsigned id;
@ -48,7 +48,7 @@ private:
int infoModus(Settings * settings); int infoModus(Settings * settings);


PageManager pageManager; PageManager pageManager;
std::vector<ka*> threadList; std::vector<ThreadData*> threadList;
unsigned nextThread; unsigned nextThread;


int convertLink(std::string redirectLink, AccountManager *accountManager, Settings * settings, int Staffel = -1, int Folge = -1, std::string allLinks = "NOT_EMPTY"); int convertLink(std::string redirectLink, AccountManager *accountManager, Settings * settings, int Staffel = -1, int Folge = -1, std::string allLinks = "NOT_EMPTY");