diff --git a/parameterManager.cpp b/parameterManager.cpp index f8a1c56..6bda544 100644 --- a/parameterManager.cpp +++ b/parameterManager.cpp @@ -51,12 +51,12 @@ int manageParameter(Settings &settings, int argc, char **argv) //Path settings if(setPaths(settings) != 0) { if(settings.debugMode) - std::cerr << " => Debug In " << __FUNCTION__ << ": setPaths f() failed." << std::endl; + std::cerr << ">>> Debug In " << __FUNCTION__ << ": setPaths f() failed." << std::endl; return -1; } if(loadDefaulOptions(settings) != 0) { if(settings.debugMode) - std::cerr << " => Debug In " << __FUNCTION__ << ": loadDefaulOptions f() failed." << std::endl; + std::cerr << ">>> Debug In " << __FUNCTION__ << ": loadDefaulOptions f() failed." << std::endl; return 28; } diff --git a/parameterManager.h b/parameterManager.h index eae957f..71fdded 100644 --- a/parameterManager.h +++ b/parameterManager.h @@ -50,7 +50,7 @@ struct Settings { proxy_ip = "127.0.0.1", languages = "GerDub,GerSub,Eng", genaueHoster = "", - version = "3.0.5", + version = "3.0.6", defaultFileVersion="1.6", outputFilePath = "", default_checkPath = "", diff --git a/programManager.cpp b/programManager.cpp index 661482b..9498e06 100644 --- a/programManager.cpp +++ b/programManager.cpp @@ -170,39 +170,40 @@ int ProgramManager::waitForThreads() int ProgramManager::sucheNach_1_Serien(Settings *settings, PageManager &pageManager, std::string &newName) { - std::string finds; + std::string finds, line; if(searchModus(settings, &finds) != 0) { if(settings->debugMode) - std::cerr << " => Debug In " << __FUNCTION__ << ": Function searchModus returned error." << std::endl; + std::cerr << ">>> Debug In " << __FUNCTION__ << ": Function searchModus returned error." << std::endl; return 24; } else if(finds.find("/") == std::string::npos || finds.find("|") == std::string::npos || finds.find("\n") != std::string::npos) { if(settings->debugMode) - std::cerr << " => Debug In " << __FUNCTION__ << ": searchModus's returnValue contains no / or |, or " << std::endl + std::cerr << ">>> Debug In " << __FUNCTION__ << ": searchModus's returnValue contains no / or |, or " << std::endl << "\t\t\tcontains an \\n => more than 1 Serie found => error." << std::endl; return 45; } else if ( (finds = finds.substr( finds.find("/") + 1, finds.find("|", finds.find("/")) - finds.find("/") -1) ) == "" ) { std::cout << " => Error: Konnte den Namen aus der zurückgegebenen Zeile nicht extrahieren." << std::endl; if(settings->debugMode) - std::cerr << " => Debug In " << __FUNCTION__ << ": Return value from searchModus.subStr(pos(/)-> next |, after /) is ''." << std::endl; + std::cerr << ">>> Debug In " << __FUNCTION__ << ": Return value from searchModus.subStr(pos(/)-> next |, after /) is ''." << std::endl; return 46; } + std::cout << "Ist das deine gewünschte Serie? Drücke nur Enter um fortzufahren: " << std::flush; - std::getline(std::cin, finds); - if ( finds != "") { + std::getline(std::cin, line); + if ( line != "") { std::cout << " => Abbruch..." << std::endl; if(settings->debugMode) - std::cerr << " => Debug In " << __FUNCTION__ << ": User tipped an Value => wrong serie." << std::endl; + std::cerr << ">>> Debug In " << __FUNCTION__ << ": User tipped an Value => wrong serie." << std::endl; return 48; } else if ( (newName = pageManager.checkName(finds)) == "-1") { 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; + std::cerr << ">>> Debug In " << __FUNCTION__ << ": Extracted Name from searchModus is invalid." << std::endl; return 47; } else { if(settings->debugMode) - std::cerr << " => Debug In " << __FUNCTION__ << ": Use new SerienName: '" << newName << "'." << std::endl; + std::cerr << ">>> Debug In " << __FUNCTION__ << ": Use new SerienName: '" << newName << "'." << std::endl; return 0; } } @@ -211,7 +212,7 @@ int ProgramManager::checkLastUpdate(Settings *settings) { if(settings->updateWarningDays == 0) { if(settings->debugMode) - std::cerr << " => Debug In " << __FUNCTION__ << ": In settings: upDateWaring is deaktivated(seted to 0)." << std::endl; + std::cerr << ">>> Debug In " << __FUNCTION__ << ": In settings: upDateWaring is deaktivated(seted to 0)." << std::endl; return 0; } @@ -219,7 +220,7 @@ int ProgramManager::checkLastUpdate(Settings *settings) if(!ifs.is_open()) { perror(("Konnte die Datei '" + settings->lastUpdateDateFilePath + "' nicht öffnen").c_str()); if(settings->debugMode) - std::cerr << " => Debug In " << __FUNCTION__ << ": Failed to open Last Update Date File:'" << settings->lastUpdateDateFilePath << "'." << std::endl; + std::cerr << ">>> Debug In " << __FUNCTION__ << ": Failed to open Last Update Date File:'" << settings->lastUpdateDateFilePath << "'." << std::endl; return 1; } std::string line; @@ -227,7 +228,7 @@ int ProgramManager::checkLastUpdate(Settings *settings) if(!std::getline(ifs, line).good()) { perror("GetLine from Date failed"); if(settings->debugMode) - std::cerr << " => Debug In " << __FUNCTION__ << ": Get the first Line of the LastUpdateDate File failed." << std::endl; + std::cerr << ">>> Debug In " << __FUNCTION__ << ": Get the first Line of the LastUpdateDate File failed." << std::endl; return 2; } else if( ( ( difDays = static_cast(pageManager.getDate()) - atoll(line.c_str()) )) >= settings->updateWarningDays) { @@ -236,7 +237,7 @@ int ProgramManager::checkLastUpdate(Settings *settings) } if(settings->debugMode) - std::cerr << " => Debug In " << __FUNCTION__ << ": Exit with success." << std::endl; + std::cerr << ">>> Debug In " << __FUNCTION__ << ": Exit with success." << std::endl; return 0; } @@ -275,7 +276,7 @@ int ProgramManager::defaultModus(Settings *settings) if(settings->default_checkPath != "") if(listDir(dirFiles, settings->default_checkPath, settings->default_maxDirs ) != 0) { if(settings->debugMode) - std::cerr << " => Debug In " << __FUNCTION__ << ": listDir failed." << std::endl; + std::cerr << ">>> Debug In " << __FUNCTION__ << ": listDir failed." << std::endl; return 28; } if(dirFiles.length() > 0) //Entferne von der liste das \n am ende @@ -290,7 +291,7 @@ int ProgramManager::defaultModus(Settings *settings) //Wenn nicht, dann fühe noch eine Suche nach ähnlichen durch && Wenn nur 1ne dacnn frag ob es diese ist. if( sucheNach_1_Serien(settings, pageManager, nameInUrl) != 0) { if(settings->debugMode) - std::cerr << " => Debug In " << __FUNCTION__ << ": sucheNach_1_Serien failed or found more options." << std::endl; + std::cerr << ">>> Debug In " << __FUNCTION__ << ": sucheNach_1_Serien failed or found more options." << std::endl; return 202; } } @@ -324,7 +325,7 @@ int ProgramManager::defaultModus(Settings *settings) if(settings->outputFilePath != "" && !fileExists( settings->default_checkPath )) if(pageManager.writeToFile(settings->outputFilePath, "Name: " + settings->name) != 0) { if(settings->debugMode) - std::cerr << " => Debug In " << __FUNCTION__ << ": writeToFile Function fails when write Name." << std::endl; + std::cerr << ">>> Debug In " << __FUNCTION__ << ": writeToFile Function fails when write Name." << std::endl; return 31; } @@ -333,7 +334,7 @@ int ProgramManager::defaultModus(Settings *settings) Reply tmp_reply = pageManager.getServerRequest(pageManager.UrlPraefix + nameInUrl); if(tmp_reply.html == "-1") { if(settings->debugMode) - std::cerr << " => Debug In " << __FUNCTION__ << ": getServerRequest failed, when download startpage." << std::endl; + std::cerr << ">>> Debug In " << __FUNCTION__ << ": getServerRequest failed, when download startpage." << std::endl; return 32; } @@ -353,7 +354,7 @@ int ProgramManager::defaultModus(Settings *settings) if(settings->maxThreads != 0) if(waitForThreads() != 0) { if(settings->debugMode) - std::cerr << " => Debug In " << __FUNCTION__ << ": Wait for the Threads failed." << std::endl; + std::cerr << ">>> Debug In " << __FUNCTION__ << ": Wait for the Threads failed." << std::endl; return 261; } if(settings->debugMode) @@ -365,7 +366,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(settings->debugMode) - std::cerr << " => Debug In " << __FUNCTION__ << ": getServerRequest failed when download season page." << std::endl; + std::cerr << ">>> Debug In " << __FUNCTION__ << ": getServerRequest failed when download season page." << std::endl; return 40; } int maxFolge = pageManager.counterContains(tmp_reply.html, "/episode-%i"); @@ -382,7 +383,7 @@ int ProgramManager::defaultModus(Settings *settings) if(settings->maxThreads != 0) if(waitForThreads() != 0) { if(settings->debugMode) - std::cerr << " => Debug In " << __FUNCTION__ << ": Wait for the Threads failed." << std::endl; + std::cerr << ">>> Debug In " << __FUNCTION__ << ": Wait for the Threads failed." << std::endl; return 261; } std::cout << " > Fertig, da Folge " << folge << " größer ist als Stopfolge " << settings->stopEpisode << "."<< std::endl; @@ -394,7 +395,7 @@ int ProgramManager::defaultModus(Settings *settings) if(settings->maxThreads != 0) if(waitForThreads() != 0) { if(settings->debugMode) - std::cerr << " => Debug In " << __FUNCTION__ << ": Wait for the Threads failed." << std::endl; + std::cerr << ">>> Debug In " << __FUNCTION__ << ": Wait for the Threads failed." << std::endl; return 267; } std::cout << " > Fertig, da Folge " << folge << " größer ist als Stopfolge " << settings->stopEpisode << std::endl @@ -421,14 +422,14 @@ int ProgramManager::defaultModus(Settings *settings) if(pthread_create(&threadList[nextThread]->thread, nullptr, threadFunction, reinterpret_cast(threadList[nextThread])) != 0 ) { perror("pthread_creat failed"); if(settings->debugMode) - std::cerr << " => Debug In " << __FUNCTION__ << ": Create thread for redirect converting failed." << std::endl; + std::cerr << ">>> Debug In " << __FUNCTION__ << ": Create thread for redirect converting failed." << std::endl; return 48; } ++nextThread; } else { // Sonnst warte bis alle Fertig sind und restarte die Folge if(waitForThreads() != 0) { if(settings->debugMode) - std::cerr << " => Debug In " << __FUNCTION__ << ": Wait for the Threads failed." << std::endl; + std::cerr << ">>> Debug In " << __FUNCTION__ << ": Wait for the Threads failed." << std::endl; return 231; } nextThread=0; @@ -442,7 +443,7 @@ int ProgramManager::defaultModus(Settings *settings) tmp_reply =pageManager.getServerRequest(pageManager.UrlPraefix + 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; + std::cerr << ">>> Debug In " << __FUNCTION__ << ": getServerRequest failed when download episoden page." << std::endl; return 50; } std::string allLinks = pageManager.getLinks(tmp_reply.html); @@ -461,13 +462,13 @@ int ProgramManager::defaultModus(Settings *settings) line.erase(line.find("\"")); if(convertLink(line, &accountManager, settings, staffel, folge, allLinks) != 0) { if(settings->debugMode) - std::cerr << " => Debug In " << __FUNCTION__ << ": convertLink failed." << std::endl; + std::cerr << ">>> Debug In " << __FUNCTION__ << ": convertLink failed." << std::endl; return 51; } } //Stop beacause same episode every account can only 2 videos not 10-12 if(settings->debugMode) - std::cerr << " => Debug In " << __FUNCTION__ << ": Stop Program, because '*'-Hoster is inperformatnt: Every Account can only 2 Vidoes not 10-12." << std::endl; + std::cerr << ">>> Debug In " << __FUNCTION__ << ": Stop Program, because '*'-Hoster is inperformatnt: Every Account can only 2 Vidoes not 10-12." << std::endl; return 0; } else { @@ -477,7 +478,7 @@ int ProgramManager::defaultModus(Settings *settings) std::cout << allLinks << std::endl << ( (Link == "") ? "" : " -> Link: 'https://s.to") << Link << ( (Link == "") ? "" : "'\n" ); if(convertLink(Link, &accountManager, settings, staffel, folge, allLinks) != 0) { if(settings->debugMode) - std::cerr << " => Debug In " << __FUNCTION__ << ": convert Link failed." << std::endl; + std::cerr << ">>> Debug In " << __FUNCTION__ << ": convert Link failed." << std::endl; return 51; } } @@ -492,7 +493,7 @@ int ProgramManager::defaultModus(Settings *settings) if(settings->maxThreads != 0) if(waitForThreads() != 0) { if(settings->debugMode) - std::cerr << " => Debug In " << __FUNCTION__ << ": Wait for the Threads failed." << std::endl; + std::cerr << ">>> Debug In " << __FUNCTION__ << ": Wait for the Threads failed." << std::endl; return 292; } @@ -524,12 +525,12 @@ int ProgramManager::directLinkModus(Settings *settings) } else if(convertLink(line.erase(0, ((line.find("s.to") == std::string::npos) ? 0 : line.find("s.to") + 4 )), &accountManager, settings) != 0) { if(settings->debugMode) - std::cerr << " => Debug In " << __FUNCTION__ << ": convert Link failed." << std::endl; + std::cerr << ">>> Debug In " << __FUNCTION__ << ": convert Link failed." << std::endl; return 78; } } if(settings->debugMode) - std::cerr << " => Debug In " << __FUNCTION__ << ": Success." << std::endl; + std::cerr << ">>> Debug In " << __FUNCTION__ << ": Success." << std::endl; return 0; } @@ -541,7 +542,7 @@ int ProgramManager::searchModus(Settings *settings, std::string *saveTo) std::cout << "Erfolgreich geupdatet: Die Serienliste ist nun auf dem neusten Stand." << std::endl; if (settings->name == "") { if(settings->debugMode) - std::cerr << " => Debug In " << __FUNCTION__ << ": Stop after Update: No Name => Only Updating." << std::endl; + std::cerr << ">>> Debug In " << __FUNCTION__ << ": Stop after Update: No Name => Only Updating." << std::endl; return 0; } @@ -562,7 +563,7 @@ int ProgramManager::searchModus(Settings *settings, std::string *saveTo) std::cout << " => Keine SerienListe vorhanden. Erstelle eine neue..." << std::endl; if(searchModus_update(settings) != 0) { if(settings->debugMode) - std::cerr << " => Debug In " << __FUNCTION__ << ": searchModus_update function failed." << std::endl; + std::cerr << ">>> Debug In " << __FUNCTION__ << ": searchModus_update function failed." << std::endl; return 354; } else { @@ -578,7 +579,7 @@ int ProgramManager::searchModus(Settings *settings, std::string *saveTo) //Check for last Update.. if(checkLastUpdate(settings) != 0) { if(settings->debugMode) - std::cerr << " => Debug In " << __FUNCTION__ << ": checkLastUpdate function failed." << std::endl; + std::cerr << ">>> Debug In " << __FUNCTION__ << ": checkLastUpdate function failed." << std::endl; return -1; } @@ -626,7 +627,7 @@ int ProgramManager::searchModus(Settings *settings, std::string *saveTo) << ( (line[0] == '|') ? "" : "\t( " + line.substr(0, line.find("|")) + " )" ) << std::endl; } if(settings->debugMode) - std::cerr << " => Debug In " << __FUNCTION__ << ": success." << std::endl; + std::cerr << ">>> Debug In " << __FUNCTION__ << ": success." << std::endl; return 0; } @@ -645,7 +646,7 @@ int ProgramManager::infoModus(Settings *settings) //Wenn nicht, dann fühe noch eine Suche nach ähnlichen durch. if( sucheNach_1_Serien(settings, pageManager, nameInUrl) != 0) { if(settings->debugMode) - std::cerr << " => Debug In " << __FUNCTION__ << ": sucheNach_1_Serien function failed." << std::endl; + std::cerr << ">>> Debug In " << __FUNCTION__ << ": sucheNach_1_Serien function failed." << std::endl; return 28; } } @@ -654,7 +655,7 @@ int ProgramManager::infoModus(Settings *settings) Reply tmp_reply = pageManager.getServerRequest(pageManager.UrlPraefix + nameInUrl); if(tmp_reply.html == "-1") { if(settings->debugMode) - std::cerr << " => Debug In " << __FUNCTION__ << ": getServerRequest function failed: at homepage." << std::endl; + std::cerr << ">>> Debug In " << __FUNCTION__ << ": getServerRequest function failed: at homepage." << std::endl; return 32; } @@ -666,7 +667,7 @@ int ProgramManager::infoModus(Settings *settings) Reply tmpReply = pageManager.getServerRequest(pageManager.UrlPraefix + 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; + std::cerr << ">>> Debug In " << __FUNCTION__ << ": getServerRequest function failed: at season page." << std::endl; return 40; } std::cout << "Die Staffel " << staffel << " hat " << pageManager.counterContains(tmpReply.html, "/episode-%i") << " Folge(n)." << std::endl; @@ -820,7 +821,7 @@ int ProgramManager::infoModus(Settings *settings) if(settings->debugMode) - std::cerr << " => Debug In " << __FUNCTION__ << ": success exit." << std::endl; + std::cerr << ">>> Debug In " << __FUNCTION__ << ": success exit." << std::endl; return 0; } @@ -830,7 +831,7 @@ int ProgramManager::newsModus(Settings *settings) std::string html = pageManager.getServerRequest("https://s.to/neue-episoden").html; if(html == "-1") { if(settings->debugMode) - std::cerr << " => Debug In " << __FUNCTION__ << ": getServerRequest function failed." << std::endl; + std::cerr << ">>> Debug In " << __FUNCTION__ << ": getServerRequest function failed." << std::endl; return 1; } @@ -896,7 +897,7 @@ int ProgramManager::searchModus_update(Settings *settings) Reply reply = pageManager.getServerRequest("https://s.to/serien"); if(reply.html == "-1") { if(settings->debugMode) - std::cerr << " => Debug In " << __FUNCTION__ << ": getServerRequest function failed." << std::endl; + std::cerr << ">>> Debug In " << __FUNCTION__ << ": getServerRequest function failed." << std::endl; return 21; } else if(reply.html.find("") == std::string::npos ) { @@ -911,7 +912,7 @@ int ProgramManager::searchModus_update(Settings *settings) reply.html.find("/serie/stream/") == std::string::npos || reply.html.find("") == std::string::npos) { if(settings->debugMode) - std::cerr << " => Debug In " << __FUNCTION__ + std::cerr << ">>> Debug In " << __FUNCTION__ << ": hatml doesnt contain:' \" href=\" or
  • ' after preparing." << std::endl; return 51; } @@ -1064,7 +1065,7 @@ int ProgramManager::convertLink(std::string redirectLink, AccountManager * accou std::cout << " => " << red << "KEINEN Hoster für die Folge " << folgenID << " gefunden." << "\033[0m" << std::endl; if(pageManager.writeToFile(settings->outputFilePath, std::string("KEINEN Hoster für die Folge ") + folgenID + std::string(" gefunden.")) != 0) { if(settings->debugMode) - std::cerr << " => Debug In " << __FUNCTION__ << ": writeToFile f() failed." << std::endl; + std::cerr << ">>> Debug In " << __FUNCTION__ << ": writeToFile f() failed." << std::endl; return 130; } } else { @@ -1074,7 +1075,7 @@ int ProgramManager::convertLink(std::string redirectLink, AccountManager * accou "data-lang-key=\"2\"", "language=\"Eng\"" ), "data-lang-key=\"3\"", "language=\"GerSub\"") << std::endl; if(pageManager.writeToFile(settings->outputFilePath, std::string("Keinen PASSENDEN Hoster für die Folge ") + folgenID + std::string(" gefunden.")) != 0) { if(settings->debugMode) - std::cerr << " => Debug In " << __FUNCTION__ << ": writeToFile f() failed." << std::endl; + std::cerr << ">>> Debug In " << __FUNCTION__ << ": writeToFile f() failed." << std::endl; return 138; } } @@ -1086,14 +1087,14 @@ int ProgramManager::convertLink(std::string redirectLink, AccountManager * accou std::string newUrl = pageManager.getUrlAfterRedirect("https://s.to" + redirectLink); if (newUrl == "-1") { if(settings->debugMode) - std::cerr << " => Debug In " << __FUNCTION__ << ": getUrlAfterRedirect f() failed." << std::endl; + std::cerr << ">>> Debug In " << __FUNCTION__ << ": getUrlAfterRedirect f() failed." << std::endl; return 102; } else if(newUrl.find("/s.to/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(settings->debugMode) - std::cerr << " => Debug In " << __FUNCTION__ << ": login f() failed." << std::endl; + std::cerr << ">>> Debug In " << __FUNCTION__ << ": login f() failed." << std::endl; return -1; } continue; @@ -1103,7 +1104,7 @@ int ProgramManager::convertLink(std::string redirectLink, AccountManager * accou if(settings->outputFilePath != "") if(pageManager.writeToFile(settings->outputFilePath,folgenID + ( (folgenID == "") ? "" : ": " ) + newUrl) != 0) { if(settings->debugMode) - std::cerr << " => Debug In " << __FUNCTION__ << ": writeToFile f() failed." << std::endl; + std::cerr << ">>> Debug In " << __FUNCTION__ << ": writeToFile f() failed." << std::endl; return 108; } return 0; @@ -1113,7 +1114,7 @@ int ProgramManager::convertLink(std::string redirectLink, AccountManager * accou if(settings->outputFilePath != "") { if(pageManager.writeToFile(settings->outputFilePath, folgenID + ( (folgenID == "") ? "" : ": " ) + redirectLink) != 0) { if(settings->debugMode) - std::cerr << " => Debug In " << __FUNCTION__ << ": writeToFile f() failed." << std::endl; + std::cerr << ">>> Debug In " << __FUNCTION__ << ": writeToFile f() failed." << std::endl; return 114; } }