forked from markus/S_New4
rename myka and ka to myThreadData and ThreadData
This commit is contained in:
parent
291e0d2acd
commit
f86e5a99b9
@ -41,73 +41,73 @@ int ProgramManager::start(Settings *settings)
|
||||
}
|
||||
}
|
||||
|
||||
void * threadFunction(void * KA) {
|
||||
ka * myka = reinterpret_cast<struct ka*>(KA);
|
||||
myka->returnValue="";
|
||||
myka->exitState=0;
|
||||
void * threadFunction(void * data) {
|
||||
ThreadData * myThreadData = reinterpret_cast<struct ThreadData*>(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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,9 +10,9 @@
|
||||
#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) {}
|
||||
|
||||
unsigned id;
|
||||
@ -48,7 +48,7 @@ private:
|
||||
int infoModus(Settings * settings);
|
||||
|
||||
PageManager pageManager;
|
||||
std::vector<ka*> threadList;
|
||||
std::vector<ThreadData*> threadList;
|
||||
unsigned nextThread;
|
||||
|
||||
int convertLink(std::string redirectLink, AccountManager *accountManager, Settings * settings, int Staffel = -1, int Folge = -1, std::string allLinks = "NOT_EMPTY");
|
||||
|
Loading…
Reference in New Issue
Block a user