forked from markus/S_New4
wenn falscher name, aber suche nur 1 ergebinis frag user ob diese serie richtig ist, wenn ja nimm diese
This commit is contained in:
parent
eea64c60f1
commit
f31df515bf
@ -130,6 +130,29 @@ int ProgramManager::waitForThreads()
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ProgramManager::sucheNach_1_Serien(Settings *settings, PageManager &pageManager, std::string &newName)
|
||||
{
|
||||
std::string finds;
|
||||
if(searchModus(settings, &finds) != 0)
|
||||
return 24;
|
||||
else if(finds.find("/") == std::string::npos || finds.find("|") == std::string::npos || finds.find("\n") != std::string::npos)
|
||||
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;
|
||||
return 46;
|
||||
} else if ( (newName = pageManager.checkName(finds)) == "-1") {
|
||||
std::cout << " => Error: Konnte die von der Suche vorgeschlagene Serie nicht finden." << std::endl;
|
||||
return 47;
|
||||
}
|
||||
std::cout << "Ist das deine gewünschte Serie? Drücke nur Enter um fortzufahren: " << std::flush;
|
||||
std::getline(std::cin, finds);
|
||||
if ( finds != "") {
|
||||
std::cout << " => Abbruch..." << std::endl;
|
||||
return 48;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ProgramManager::defaultModus(Settings *settings)
|
||||
{
|
||||
AccountManager accountManager(settings->accountFilePath, settings->accountNumberPath);
|
||||
@ -174,9 +197,9 @@ int ProgramManager::defaultModus(Settings *settings)
|
||||
//Führe Function aus, die überprüft ob die serie existiert
|
||||
std::string nameInUrl =pageManager.checkName(settings->name);
|
||||
if(nameInUrl == "-1") {
|
||||
//Wenn nicht, dann fühe noch eine Suche nach ähnlichen durch.
|
||||
searchModus(settings);
|
||||
return 25;
|
||||
//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)
|
||||
return 202;
|
||||
}
|
||||
|
||||
/* Wenn multihtreading seaktiviert ist, normal login sonst bereite threads vor
|
||||
@ -344,7 +367,7 @@ int ProgramManager::directLinkModus(Settings *settings)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ProgramManager::searchModus(Settings *settings)
|
||||
int ProgramManager::searchModus(Settings *settings, std::string *saveTo)
|
||||
{
|
||||
if(settings->search_wantUpdate) {
|
||||
int res = searchModus_update(settings) ;
|
||||
@ -391,6 +414,11 @@ int ProgramManager::searchModus(Settings *settings)
|
||||
finds.insert(pos, ( (finds.find(settings->name, pos) == pos) ? "\033[32m" : "\033[36m" ) ).insert(pos + settings->name.length() + strlen("\033[37m"), "\033[0m");
|
||||
}*/
|
||||
|
||||
if(saveTo) {
|
||||
//Save List to Variable if set
|
||||
*saveTo=finds;
|
||||
}
|
||||
|
||||
//Text mit Farben versehen
|
||||
if(!settings->colorless) {
|
||||
std::string UpperFinds = pageManager.upper_string( finds );
|
||||
@ -431,8 +459,8 @@ int ProgramManager::infoModus(Settings *settings)
|
||||
std::string nameInUrl = pageManager.checkName(settings->name);
|
||||
if(nameInUrl == "-1") {
|
||||
//Wenn nicht, dann fühe noch eine Suche nach ähnlichen durch.
|
||||
searchModus(settings);
|
||||
return 25;
|
||||
if( sucheNach_1_Serien(settings, pageManager, nameInUrl) != 0)
|
||||
return 28;
|
||||
}
|
||||
|
||||
//Finde Anzahl der Staffel heraus:
|
||||
|
@ -44,7 +44,7 @@ public:
|
||||
private:
|
||||
int defaultModus(Settings * settings);
|
||||
int directLinkModus(Settings * settings);
|
||||
int searchModus(Settings * settings);
|
||||
int searchModus(Settings * settings, std::string *saveTo = nullptr);
|
||||
int infoModus(Settings * settings);
|
||||
|
||||
PageManager pageManager;
|
||||
@ -54,6 +54,7 @@ private:
|
||||
int convertLink(std::string redirectLink, AccountManager *accountManager, Settings * settings, int Staffel = -1, int Folge = -1, std::string allLinks = "NOT_EMPTY");
|
||||
int searchModus_update(Settings * settings);
|
||||
int waitForThreads();
|
||||
int sucheNach_1_Serien(Settings *settings, PageManager &pageManager, std::string &newName);
|
||||
|
||||
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user