From 461aae2d5bd82e627c991e6d15dce8a668b738e5 Mon Sep 17 00:00:00 2001 From: M4RKUS28 Date: Tue, 26 Sep 2023 04:12:36 +0200 Subject: [PATCH] Fix wrong name output when using wrong name as input, e.g. -d one piese -> Serie: one piese -> jetzt One Piece --- src/S_New4.pro | 4 ++-- src/pageManager.cpp | 25 +++++++++++++++++-------- src/pageManager.h | 6 +++--- src/parameterManager.h | 2 +- src/programManager.cpp | 12 ++++++++---- 5 files changed, 31 insertions(+), 18 deletions(-) diff --git a/src/S_New4.pro b/src/S_New4.pro index f0408c9..b67cc37 100644 --- a/src/S_New4.pro +++ b/src/S_New4.pro @@ -1,5 +1,5 @@ QT -= gui core -#CONFIG += -static -libstdc++ -static-libgcc #-static +#CONFIG += -libstdc++ -static-libgcc #-static #QT += core gui @@ -11,7 +11,7 @@ QT -= gui core unix: LIBS += -lcurl #Windows -win32: LIBS += -L$${_PRO_FILE_PWD_}\..\lib\ -lcurl # 7.82.0 +win32: LIBS += -L$${_PRO_FILE_PWD_}\..\lib\ -lcurl # 8.2.1 #win32: LIBS += -L$${_PRO_FILE_PWD_}\..\alt\ -lcurl # 7.64.1 diff --git a/src/pageManager.cpp b/src/pageManager.cpp index 69c677e..a4b94b6 100644 --- a/src/pageManager.cpp +++ b/src/pageManager.cpp @@ -447,7 +447,7 @@ checkNameRply PageManager::checkName(std::vector &pages, std::string Name, { if(pages.size() < 1) { std::cout << " => Error Keine Internet Seiten vorhanden." << std::endl; - return checkNameRply("", PAGE(), checkNameRply::FAILED); + return checkNameRply("", "", PAGE(), checkNameRply::FAILED); } //überprüfe, auf welchen seite die serie existiert, wenn parameter @@ -456,6 +456,7 @@ checkNameRply PageManager::checkName(std::vector &pages, std::string Name, int count = 0; std::string name = replace(Name, " ", "-"); std::string pagesonExist; + std::string correct_name = name; PAGE Page; //für jede Seite @@ -477,8 +478,7 @@ checkNameRply PageManager::checkName(std::vector &pages, std::string Name, } else if( html.find("DDOS-GUARD") != std::string::npos ) { std::cout << "\33[2K\r" <<" => WARNUNG: Die Seite : '" << pages.at(i).url << "' benötigt ein DDOS-GUARD hCaptcha!" << std::endl; - writeToFile( outPutFilePaths, html ); - +// writeToFile( outPutFilePaths, html ); pages.erase(pages.begin() + i); i--; continue; @@ -488,6 +488,15 @@ checkNameRply PageManager::checkName(std::vector &pages, std::string Name, pagesonExist += pages.at(i).url + " "; Page = pages.at(i); + std::string tryGetGoodName = this->grep(html, " 4) { + size_t pos1 = tryGetGoodName.find(""); + size_t pos2 = tryGetGoodName.find(""); + if(pos1 != std::string::npos && pos2 != std::string::npos) { + correct_name = tryGetGoodName.substr(pos1 + 6, pos2 - pos1 - 6); + } + } + if(useFirstPage) { if(debugMode) std::cerr << "Nimm gleiche diese Seite, da useFirstPage auf true ist: " << pages.at(i).url << std::endl; @@ -501,22 +510,22 @@ checkNameRply PageManager::checkName(std::vector &pages, std::string Name, for( auto &path : outPutFilePaths) path = replace(path, "%URLNAME%", name); checkFilePath = replace(checkFilePath, "%URLNAME%", name); - std::cout << "\33[2K\r > Serie: " << Name << " (" << name << ")" << std::endl; + std::cout << "\33[2K\r > Serie: " << correct_name << " (" << name << ")" << std::endl; - return checkNameRply(name, Page, checkNameRply::SUCCESS);; + return checkNameRply(correct_name, name, Page, checkNameRply::SUCCESS);; } else if ( count > 1) { std::cout << "\33[2K\r => Die Serie existiert auf mehreren Seiten " << name << ": '" << pagesonExist << "'" << std::endl; std::cout << "\33[2K\r Benutze die Option -f --use-first, um automatisch die 1. Seite zu verwenden!" << std::endl; - return checkNameRply("", PAGE(), checkNameRply::MULTIPLE_OPTIONS); //MULTIPLE OPTIONS FOUND!!!! same option -> führe suche funktion aus + return checkNameRply(correct_name, "", PAGE(), checkNameRply::MULTIPLE_OPTIONS); //MULTIPLE OPTIONS FOUND!!!! same option -> führe suche funktion aus } else if( count == 0 && pages.size() == 0) { //keine suche wenn es keine funktionierende seite gibt - return checkNameRply("", PAGE(), checkNameRply::NO_WORKING_PAGE); + return checkNameRply(Name, "", PAGE(), checkNameRply::NO_WORKING_PAGE); } // führe suche aus... else { std::cout << "\33[2K\r => Die gewünschte Serie wurde nicht gefunden oder ist im Moment deaktiviert: '" << Name << "'" << std::endl; - return checkNameRply("", PAGE(), checkNameRply::NOTHING_FOUND); + return checkNameRply(Name, "", PAGE(), checkNameRply::NOTHING_FOUND); } } diff --git a/src/pageManager.h b/src/pageManager.h index 06a9a8a..4308f6e 100644 --- a/src/pageManager.h +++ b/src/pageManager.h @@ -37,14 +37,14 @@ struct Reply { }; struct checkNameRply { - std::string name; + std::string correct_name, url_name; PAGE pageInUse; enum STATUS { SUCCESS, FAILED, NOTHING_FOUND, MULTIPLE_OPTIONS, NO_WORKING_PAGE } status; - checkNameRply(const std::string &name, const PAGE &p, const checkNameRply::STATUS &s ) - : name(name), pageInUse(p), status(s) {} + checkNameRply(const std::string &correct_name, const std::string &url_name, const PAGE &p, const checkNameRply::STATUS &s ) + : correct_name(correct_name), url_name(url_name), pageInUse(p), status(s) {} }; diff --git a/src/parameterManager.h b/src/parameterManager.h index 0536452..bd4a908 100644 --- a/src/parameterManager.h +++ b/src/parameterManager.h @@ -25,7 +25,7 @@ #define UpdaterCloudUrlWithPath "https://cloud.obermui.de/s/tXz7SWdaPJ7TacZ/download?path=%2F&files=" #define SecondUpdaterCloudUrlWithPath "https://snew4.obermui.de/download?path=%2F&files=" -#define VERSION "6.1.1" +#define VERSION "6.2.0" #define DEFAULT_FILE_VERSION "2.5" //default, anime, normal, diff --git a/src/programManager.cpp b/src/programManager.cpp index 5c0c47c..6612f78 100644 --- a/src/programManager.cpp +++ b/src/programManager.cpp @@ -380,9 +380,11 @@ int ProgramManager::sucheNach_1_Serien(Settings *settings, PageManager &pageMana } else { //speichere neuen Namen in übergebenen ref var - newNameAndPage.name = ret.name; + newNameAndPage.url_name = ret.url_name; + newNameAndPage.correct_name = ret.correct_name; + if(settings->debugMode) - std::cerr << ">>> Debug In " << __FUNCTION__ << ": Use new SerienName: '" << ret.name << "'." << std::endl; + std::cerr << ">>> Debug In " << __FUNCTION__ << ": Use new SerienName: '" << ret.correct_name << "' (" << ret.url_name << ")." << std::endl; return 0; } } @@ -578,7 +580,8 @@ int ProgramManager::defaultModus(Settings *settings) return 0; } - std::string nameInUrl = retVal.name; + std::string nameInUrl = retVal.url_name; + settings->name = retVal.correct_name; PAGE page = retVal.pageInUse; AccountManager accountManager(settings->accountFilePath, settings->accountNumberPath, page, settings->pagesALL); @@ -1158,7 +1161,8 @@ int ProgramManager::infoModus(Settings *settings) std::cerr << ">>> Debug In " << __FUNCTION__ << ": Keine Funktionierende Internetseite!" << std::endl; return 0; } - std::string nameInUrl = retV.name; + std::string nameInUrl = retV.url_name; + settings->name = retV.correct_name; PAGE page = retV.pageInUse; // std::cout << "Serie: " + settings->name + " (" + nameInUrl + ")" << std::endl;