|
|
|
@ -103,12 +103,10 @@ void * threadFunction(void * KA) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int ProgramManager::defaultModus(Settings *settings)
|
|
|
|
|
{
|
|
|
|
|
AccountManager accountManager(settings->accountFilePath, settings->accountNumberPath);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Wenn kein Name mit -n Angegeben wurde:
|
|
|
|
|
if(settings->name == "") {
|
|
|
|
|
if(settings->default_checkDirPath != "") {
|
|
|
|
@ -157,28 +155,30 @@ int ProgramManager::defaultModus(Settings *settings)
|
|
|
|
|
return 25;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Wenn multihtreading seaktiviert ist, normal login sonst bereite threads vor
|
|
|
|
|
if(settings->maxThreads == 0) {
|
|
|
|
|
// melde bei s.to an und speicher cookies.
|
|
|
|
|
if (pageManager.login(accountManager.getNextAccount()) != 0) //----------------------------------------
|
|
|
|
|
return 29;
|
|
|
|
|
} else {
|
|
|
|
|
for (unsigned i = 0; i < settings->maxThreads; ++i) {
|
|
|
|
|
ka * newKa = new ka(i);
|
|
|
|
|
PageManager * pm = new PageManager;
|
|
|
|
|
pm->setProxy(settings->proxy_ip, settings->proxy_port);
|
|
|
|
|
pm->setCookieFilePath(settings->cookieFilePath + std::to_string( i ));
|
|
|
|
|
pm->setDebugMode(settings->debugMode);
|
|
|
|
|
newKa->pageManager = pm;
|
|
|
|
|
|
|
|
|
|
for (unsigned i = 0; i < settings->maxThreads; ++i) {
|
|
|
|
|
ka * newKa = new ka(i);
|
|
|
|
|
PageManager * pm = new PageManager;
|
|
|
|
|
pm->setProxy(settings->proxy_ip, settings->proxy_port);
|
|
|
|
|
pm->setCookieFilePath(settings->cookieFilePath + std::to_string( i ));
|
|
|
|
|
pm->setDebugMode(settings->debugMode);
|
|
|
|
|
newKa->pageManager = pm;
|
|
|
|
|
|
|
|
|
|
newKa->settings = settings;
|
|
|
|
|
newKa->accountManager = &accountManager;
|
|
|
|
|
newKa->nameInUrl = nameInUrl;
|
|
|
|
|
threadList.push_back(newKa);
|
|
|
|
|
newKa->settings = settings;
|
|
|
|
|
newKa->accountManager = &accountManager;
|
|
|
|
|
newKa->nameInUrl = nameInUrl;
|
|
|
|
|
newKa->thread = 0; // Sonst error wenn join & nicht gesetzt
|
|
|
|
|
newKa->exitState = -1;
|
|
|
|
|
threadList.push_back(newKa);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// melde bei s.to an und speicher cookies.
|
|
|
|
|
if (pageManager.login(accountManager.getNextAccount()) != 0) //----------------------------------------
|
|
|
|
|
return 29;
|
|
|
|
|
//Write Name to File if -o is set
|
|
|
|
|
pageManager.writeToFile(settings->outputFilePath, "Name: " + settings->name);
|
|
|
|
|
|
|
|
|
|
//Finde die anzahl der staffel heraus:
|
|
|
|
@ -217,70 +217,49 @@ int ProgramManager::defaultModus(Settings *settings)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Wenn nex Thread noch in den Vector passt(weniger Threads als Max), dann Starte neuen mit data aus dem Vector...
|
|
|
|
|
if(nextThread < threadList.size()) {
|
|
|
|
|
threadList[nextThread]->setData(staffel, folge);
|
|
|
|
|
if(pthread_create(&threadList[nextThread]->thread, nullptr, threadFunction, reinterpret_cast<void*>(threadList[nextThread])) != 0 ) {
|
|
|
|
|
perror("pthread_creat failed");
|
|
|
|
|
return 48;
|
|
|
|
|
}
|
|
|
|
|
nextThread++;
|
|
|
|
|
} else { // Sonnst warte bis alle Fertig sind und restarte die Folge
|
|
|
|
|
for( auto &e : threadList) {
|
|
|
|
|
pthread_join(e->thread, nullptr);
|
|
|
|
|
if(e->exitState != 0) {
|
|
|
|
|
std::cout << "Error: Thread gab error zurück." << std::endl;
|
|
|
|
|
return e->exitState;
|
|
|
|
|
//Multihreading Mode
|
|
|
|
|
if(settings->maxThreads > 0) {
|
|
|
|
|
//Wenn nex Thread noch in den Vector passt(weniger Threads als Max), dann Starte neuen mit data aus dem Vector...
|
|
|
|
|
if(nextThread < threadList.size()) {
|
|
|
|
|
threadList[nextThread]->exitState = 0;
|
|
|
|
|
threadList[nextThread]->setData(staffel, folge);
|
|
|
|
|
if(pthread_create(&threadList[nextThread]->thread, nullptr, threadFunction, reinterpret_cast<void*>(threadList[nextThread])) != 0 ) {
|
|
|
|
|
perror("pthread_creat failed");
|
|
|
|
|
return 48;
|
|
|
|
|
}
|
|
|
|
|
std::cout << "NachThread: " << e->returnValue << std::endl;
|
|
|
|
|
nextThread++;
|
|
|
|
|
} else { // Sonnst warte bis alle Fertig sind und restarte die Folge
|
|
|
|
|
if(waitForThreads() != 0)
|
|
|
|
|
return 231;
|
|
|
|
|
nextThread=0;
|
|
|
|
|
folge--;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
nextThread=0;
|
|
|
|
|
folge--;
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
} else { // Default Mode
|
|
|
|
|
tmp_reply =pageManager.getServerRequest(pageManager.UrlPraefix + nameInUrl + "/staffel-" + std::to_string(staffel) + "/episode-" + std::to_string(folge));
|
|
|
|
|
if(tmp_reply.html == "-1")
|
|
|
|
|
return 50;
|
|
|
|
|
std::string allLinks = pageManager.getLinks(tmp_reply.html);
|
|
|
|
|
std::string Link = pageManager.chooseHosterLink(allLinks, settings->genaueHoster, settings->languages);
|
|
|
|
|
|
|
|
|
|
if(settings->debugMode)
|
|
|
|
|
std::cout << allLinks << std::endl << ( (Link == "") ? "" : " -> Link: 'https://s.to") << Link << ( (Link == "") ? "" : "'\n" );
|
|
|
|
|
if(convertLink(Link, &accountManager, settings, staffel, folge, allLinks) != 0)
|
|
|
|
|
return 51;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
tmp_reply =pageManager.getServerRequest(pageManager.UrlPraefix + nameInUrl + "/staffel-" + std::to_string(staffel) + "/episode-" + std::to_string(folge));
|
|
|
|
|
if(tmp_reply.html == "-1")
|
|
|
|
|
return 50;
|
|
|
|
|
std::string allLinks = pageManager.getLinks(tmp_reply.html);
|
|
|
|
|
std::string Link = pageManager.chooseHosterLink(allLinks, settings->genaueHoster, settings->languages);
|
|
|
|
|
|
|
|
|
|
if(settings->debugMode)
|
|
|
|
|
std::cout << allLinks << std::endl << ( (Link == "") ? "" : " -> Link: 'https://s.to") << Link << ( (Link == "") ? "" : "'\n" );
|
|
|
|
|
if(convertLink(Link, &accountManager, settings, staffel, folge, allLinks) != 0)
|
|
|
|
|
return 51;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(folge == settings->stopEpisode && settings->stopSeason < 1) { // stoppe wenn stopfolge gleich der folge ist und stopstaffel nicht gesetzt wurde.
|
|
|
|
|
for( auto &e : threadList) {
|
|
|
|
|
pthread_join(e->thread, nullptr);
|
|
|
|
|
if(e->exitState != 0) {
|
|
|
|
|
std::cout << "Error: Thread gab error zurück." << std::endl;
|
|
|
|
|
return e->exitState;
|
|
|
|
|
}
|
|
|
|
|
std::cout << "NachThread: " << e->returnValue << std::endl;
|
|
|
|
|
}
|
|
|
|
|
if(settings->maxThreads != 0)
|
|
|
|
|
if(waitForThreads() != 0)
|
|
|
|
|
return 261;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
else if ( folge == settings->stopEpisode && staffel == settings->stopSeason) { // stoppe wenn stopfolge = folge && stopstaffel == staffel
|
|
|
|
|
for( auto &e : threadList) {
|
|
|
|
|
pthread_join(e->thread, nullptr);
|
|
|
|
|
if(e->exitState != 0) {
|
|
|
|
|
std::cout << "Error: Thread gab error zurück." << std::endl;
|
|
|
|
|
return e->exitState;
|
|
|
|
|
}
|
|
|
|
|
std::cout << "NachThread: " << e->returnValue << std::endl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else if ( folge == settings->stopEpisode && staffel == settings->stopSeason) { // stoppe wenn stopfolge = folge && stopstaffel == staffel
|
|
|
|
|
if(settings->maxThreads != 0)
|
|
|
|
|
if(waitForThreads() != 0)
|
|
|
|
|
return 267;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -294,22 +273,34 @@ int ProgramManager::defaultModus(Settings *settings)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for( auto &e : threadList) {
|
|
|
|
|
pthread_join(e->thread, nullptr);
|
|
|
|
|
if(e->exitState != 0) {
|
|
|
|
|
std::cout << "Error: Thread gab error zurück." << std::endl;
|
|
|
|
|
return e->exitState;
|
|
|
|
|
}
|
|
|
|
|
std::cout << "NachThread: " << e->returnValue << std::endl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(settings->maxThreads != 0)
|
|
|
|
|
if(waitForThreads() != 0)
|
|
|
|
|
return 292;
|
|
|
|
|
|
|
|
|
|
std::cout << " > Fertig" << std::endl;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int ProgramManager::waitForThreads()
|
|
|
|
|
{
|
|
|
|
|
for( auto &e : threadList) {
|
|
|
|
|
if( e->exitState != -1 && pthread_join(e->thread, nullptr) == 0) {
|
|
|
|
|
if(e->exitState != 0) {
|
|
|
|
|
std::cout << "Error: Thread gab error zurück." << std::endl;
|
|
|
|
|
return e->exitState;
|
|
|
|
|
} else
|
|
|
|
|
if(e->returnValue != "")
|
|
|
|
|
std::cout << "(T" << e->id << ")" << e->returnValue << std::endl;
|
|
|
|
|
}
|
|
|
|
|
e->exitState = -1;
|
|
|
|
|
e->returnValue = "";
|
|
|
|
|
e->setData(0, 0);
|
|
|
|
|
e->thread = 0;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int ProgramManager::directLinkModus(Settings *settings)
|
|
|
|
|
{
|
|
|
|
|
AccountManager accountManager(settings->accountFilePath, settings->accountNumberPath);
|
|
|
|
|