Fix wrong name output when using wrong name as input, e.g. -d one piese

-> Serie: one piese -> jetzt One Piece
This commit is contained in:
M4RKUS28 2023-09-26 04:12:36 +02:00
parent e1a842e15f
commit 461aae2d5b
5 changed files with 31 additions and 18 deletions

View File

@ -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



View File

@ -447,7 +447,7 @@ checkNameRply PageManager::checkName(std::vector<PAGE> &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<PAGE> &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<PAGE> &pages, std::string Name,

} else if( html.find("<!DOCTYPE html><html><head><title>DDOS-GUARD</title>") != 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<PAGE> &pages, std::string Name,
pagesonExist += pages.at(i).url + " ";
Page = pages.at(i);

std::string tryGetGoodName = this->grep(html, "<h1");
if(tryGetGoodName.length() > 4) {
size_t pos1 = tryGetGoodName.find("<span>");
size_t pos2 = tryGetGoodName.find("</span>");
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<PAGE> &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);
}

}

View File

@ -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) {}
};



View File

@ -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,

View File

@ -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;