diff --git a/src/pageManager.cpp b/src/pageManager.cpp index 3a0ed83..126c83b 100644 --- a/src/pageManager.cpp +++ b/src/pageManager.cpp @@ -339,7 +339,7 @@ std::string PageManager::replace(std::string str, std::string substr1, std::stri if(substr1 == "") return str; size_t index = 0; - for (index = str.find(substr1, index); index != std::string::npos; index = str.find(substr1, index + substr1.length()) ) + for (index = str.find(substr1, index); index != std::string::npos; index = str.find(substr1, index + substr1.length() +1) ) str.replace(index, substr1.length(), substr2); return str; } diff --git a/src/parameterManager.h b/src/parameterManager.h index 1900089..51f5eed 100644 --- a/src/parameterManager.h +++ b/src/parameterManager.h @@ -83,7 +83,7 @@ struct Settings { proxy_ip = "127.0.0.1", languages = "GerDub,GerSub,Eng,", genaueHoster = "", - version = "3.9.0", + version = "3.9.1", defaultFileVersion="1.8", default_checkPath = "", default_Searchmuster = "S%Staffel%E%Folge%"; diff --git a/src/programManager.cpp b/src/programManager.cpp index fc566b9..92e25a2 100644 --- a/src/programManager.cpp +++ b/src/programManager.cpp @@ -82,21 +82,23 @@ void * threadFunction(void * data) { if(Link == "") { //Wenn gar keine Links vorhanden sind: if(allLinks == "") { - myThreadData->returnValue = " => " + red + "KEINEN Hoster für die Folge " + folgenID + " gefunden." + clearColor; - if(myThreadData->pageManager->writeToFile(myThreadData->settings->outputFilePaths, std::string("KEINEN Hoster für die Folge ") + folgenID + std::string(" gefunden.")) != 0) { + myThreadData->returnValue = " => " + red + "KEINEN Hoster für die Folge " + myThreadData->pageManager->replace(folgenID, "E", " E") + " gefunden." + clearColor; + if(myThreadData->pageManager->writeToFile(myThreadData->settings->outputFilePaths, std::string("KEINEN Hoster für die Folge ") + + myThreadData->pageManager->replace(folgenID, "E", " E") + std::string(" gefunden.")) != 0) { if(myThreadData->settings->debugMode) std::cerr << " => Debug: In Thread: "<< myThreadData->id << ": writeToFile Function failed." << std::endl; return myThreadData->setState(14); } //Wenn nur kein passender Link gefunden wurde: } else { - myThreadData->returnValue = " => " + orange + "Keinen PASSENDEN Hoster für die Folge " + folgenID + " gefunden." + clearColor + "\n" + myThreadData->returnValue = " => " + orange + "Keinen PASSENDEN Hoster für die Folge " + myThreadData->pageManager->replace(folgenID, "E", " E") + " gefunden." + clearColor + "\n" + "Alle Links:" + "\n" + 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(myThreadData->pageManager->writeToFile(myThreadData->settings->outputFilePaths, - std::string("Keinen PASSENDEN Hoster für die Folge ") + folgenID + std::string(" gefunden.")) != 0) { + std::string("Keinen PASSENDEN Hoster für die Folge ") + myThreadData->pageManager->replace(folgenID, "E", " E") + + std::string(" gefunden.")) != 0) { if(myThreadData->settings->debugMode) std::cerr << " => Debug: In Thread: "<< myThreadData->id << ": writeToFile Function failed." << std::endl; return myThreadData->setState(15); @@ -142,9 +144,10 @@ void * threadFunction(void * data) { } } - myThreadData->returnValue = " => " + folgenID + ( (folgenID == "") ? "" : ": " ) + red + "https://s.to" + Link + clearColor; + //error at 3 time + myThreadData->returnValue = " => " + myThreadData->pageManager->replace(folgenID, "E", " E") + ( (folgenID == "") ? "" : ": " ) + red + "https://s.to" + Link + clearColor; if(myThreadData->settings->outputFilePaths.size() != 0) - if(myThreadData->pageManager->writeToFile(myThreadData->settings->outputFilePaths, folgenID + ( (folgenID == "") ? "" : ": " ) + Link) != 0) { + if(myThreadData->pageManager->writeToFile(myThreadData->settings->outputFilePaths, myThreadData->pageManager->replace(folgenID, "E", " E") + ( (folgenID == "") ? "" : ": " ) + Link) != 0) { if(myThreadData->settings->debugMode) std::cerr << " => Debug: In Thread: "<< myThreadData->id << ": writeToFile Function failed." << std::endl; return myThreadData->setState(19); @@ -1481,18 +1484,18 @@ int ProgramManager::convertLink(std::string redirectLink, AccountManager * accou if(redirectLink == "" && settings->modus == Modus::DEFAULT_MODUS) { if(allLinks == "") { - std::cout << " => " << red << "KEINEN Hoster für die Folge " << folgenID << " gefunden." << ((settings->colorless) ? "" : "\033[0m") << std::endl; - if(pageManager.writeToFile(settings->outputFilePaths, std::string("KEINEN Hoster für die Folge ") + folgenID + std::string(" gefunden.")) != 0) { + std::cout << " => " << red << "KEINEN Hoster für die Folge " << pageManager.replace(folgenID, "E", " E") << " gefunden." << ((settings->colorless) ? "" : "\033[0m") << std::endl; + if(pageManager.writeToFile(settings->outputFilePaths, std::string("KEINEN Hoster für die Folge ") + pageManager.replace(folgenID, "E", " E") + std::string(" gefunden.")) != 0) { if(settings->debugMode) std::cerr << ">>> Debug In " << __FUNCTION__ << ": writeToFile f() failed." << std::endl; return 130; } } else { - std::cout << " => " << orange << "Keinen PASSENDEN Hoster für die Folge " << folgenID << " gefunden." << ((settings->colorless) ? "" : "\033[0m") << std::endl + std::cout << " => " << orange << "Keinen PASSENDEN Hoster für die Folge " << pageManager.replace(folgenID, "E", " E") << " gefunden." << ((settings->colorless) ? "" : "\033[0m") << std::endl << "Alle Links:" << std::endl << pageManager.replace( pageManager.replace( pageManager.replace( allLinks, "data-lang-key=\"1\"", "language=\"GerDub\"" ), "data-lang-key=\"2\"", "language=\"Eng\"" ), "data-lang-key=\"3\"", "language=\"GerSub\"") << std::endl; - if(pageManager.writeToFile(settings->outputFilePaths, std::string("Keinen PASSENDEN Hoster für die Folge ") + folgenID + std::string(" gefunden.")) != 0) { + if(pageManager.writeToFile(settings->outputFilePaths, std::string("Keinen PASSENDEN Hoster für die Folge ") + pageManager.replace(folgenID, "E", " E") + std::string(" gefunden.")) != 0) { if(settings->debugMode) std::cerr << ">>> Debug In " << __FUNCTION__ << ": writeToFile f() failed." << std::endl; return 138; @@ -1523,10 +1526,10 @@ int ProgramManager::convertLink(std::string redirectLink, AccountManager * accou //wenn nach der Umwandlung https://s.to/ vorhanden ist, die ist wenn der Link Ungültig war: } else if (newUrl == "https://s.to/") { - std::cout << " => " << red << folgenID << ( (folgenID == "") ? "" : ": " ) << "Ungültige Url: 'https://s.to" << redirectLink << "'" + std::cout << " => " << red << pageManager.replace(folgenID, "E", " E") << ( (folgenID == "") ? "" : ": " ) << "Ungültige Url: 'https://s.to" << redirectLink << "'" << ((settings->colorless) ? "" : "\033[0m") << std::endl; if(settings->outputFilePaths.size() != 0) - if(pageManager.writeToFile(settings->outputFilePaths, folgenID + ( (folgenID == "") ? "" : ": " ) + "Ungültige Url: https://s.to" + redirectLink) != 0) { + if(pageManager.writeToFile(settings->outputFilePaths, pageManager.replace(folgenID, "E", " E") + ( (folgenID == "") ? "" : ": " ) + "Ungültige Url: https://s.to" + redirectLink) != 0) { if(settings->debugMode) std::cerr << ">>> Debug In " << __FUNCTION__ << ": writeToFile f() failed." << std::endl; return 108; @@ -1546,9 +1549,9 @@ int ProgramManager::convertLink(std::string redirectLink, AccountManager * accou } //nach 3temn Versuch gib error aus: - std::cout << " => " << folgenID << ( (folgenID == "") ? "" : ": " ) << red << "https://s.to" << redirectLink << ((settings->colorless) ? "" : "\033[0m") << std::endl; + std::cout << " => " << pageManager.replace(folgenID, "E", " E") << ( (folgenID == "") ? "" : ": " ) << red << "https://s.to" << redirectLink << ((settings->colorless) ? "" : "\033[0m") << std::endl; if(settings->outputFilePaths.size() != 0) { - if(pageManager.writeToFile(settings->outputFilePaths, folgenID + ( (folgenID == "") ? "" : ": " ) + redirectLink) != 0) { + if(pageManager.writeToFile(settings->outputFilePaths, pageManager.replace(folgenID, "E", " E") + ( (folgenID == "") ? "" : ": " ) + redirectLink) != 0) { if(settings->debugMode) std::cerr << ">>> Debug In " << __FUNCTION__ << ": writeToFile f() failed." << std::endl; return 114;