diff --git a/src/parameterManager.cpp b/src/parameterManager.cpp index 8017535..46a4ba4 100644 --- a/src/parameterManager.cpp +++ b/src/parameterManager.cpp @@ -775,12 +775,13 @@ int unterOption_search(Settings *settings, int argc, char **argv) {"debug-mode", no_argument, nullptr, 'd'}, {"exactly-writing", no_argument, nullptr, 'e'}, {"update", no_argument, nullptr, 'u'}, + {"last-update", no_argument, nullptr, 'l'}, {nullptr, no_argument, nullptr, 0} }; - while( ( c = getopt_long (argc, argv, "p:hcdeu", long_opts, nullptr) ) != -1 ) { + while( ( c = getopt_long (argc, argv, "p:hcdeul", long_opts, nullptr) ) != -1 ) { switch(c) { case 'p': if(!optarg || setS5ProxytoSettings(*settings, optarg) != 0) @@ -809,6 +810,11 @@ int unterOption_search(Settings *settings, int argc, char **argv) if(settings->debugMode) std::cout << "Update die Liste: true" << std::endl; break; + case 'l': + settings->showLastUpdate = true; + if(settings->debugMode) + std::cout << "showLastUpdate: true" << std::endl; + break; default: std::cout << "Aufruf: " << settings->programName << " search [OPTION]... [NAME]..." << std::endl; std::cout << "\"" << settings->programName << " search --help\" liefert weitere Informationen." << std::endl; @@ -836,8 +842,8 @@ int unterOption_search(Settings *settings, int argc, char **argv) void unterOption_search_help(std::string programName) { std::cout << "Aufruf: " << programName << " search [OPTION]... [NAME]" << std::endl - << " " << programName << " search [-u, --update] [OPTION]... [NAME]" << std::endl - << " " << programName << " search [-u, --update]" << std::endl << std::endl; + << " " << programName << " search [OPTION]... [{-u, --update}&|/{-l, --last-update}]" << std::endl + << " " << programName << " search [OPTION]... [{-u, --update}&|/{-l, --last-update}] [Name]" << std::endl << std::endl; std::cout << "Beschreibung:" << std::endl << " Mit dieser Unterfunktion des Programms kann man Serien auf s.to suchen." << std::endl @@ -863,6 +869,9 @@ void unterOption_search_help(std::string programName) << " Standart: 127.0.0.1:9050 - Port 0 um Proxy zu deaktivieren." << std::endl << std::endl << " -e, --exactly-writing" << std::endl << " Mit dieser Option achtet das Programm auf Groß- und Kleinschreibung." << std::endl << std::endl + << " -l, --last-update" << std::endl + << " Mit dieser Option wird ausgegeben, vor wie vielen Tagen die" << std::endl + << " Serienliste zuletzt aktualisiert wurde." << std::endl << std::endl << " -c, --colorless" << std::endl << " Mit dieser Option kann man die farbige Ausgabe ausstellen." << std::endl << std::endl << " -d, --debug-mode" << std::endl diff --git a/src/parameterManager.h b/src/parameterManager.h index 2e28466..743ff01 100644 --- a/src/parameterManager.h +++ b/src/parameterManager.h @@ -81,7 +81,7 @@ struct Settings { proxy_ip = "127.0.0.1", languages = "GerDub,GerSub,Eng,", genaueHoster = "", - version = "3.6.3", + version = "3.7.0", defaultFileVersion="1.6", outputFilePath = "", default_checkPath = "", @@ -93,7 +93,8 @@ struct Settings { search_IgnoreUpperLower = true, search_wantUpdate = false, askForEveryDir = true, - skipEpisodenNameOutput = false; + skipEpisodenNameOutput = false, + showLastUpdate = false; int startEpisode = 1, stopEpisode = 0, startSeason = 1, diff --git a/src/programManager.cpp b/src/programManager.cpp index 65dbfe8..50ad4a4 100644 --- a/src/programManager.cpp +++ b/src/programManager.cpp @@ -292,9 +292,10 @@ int ProgramManager::sucheNach_1_Serien(Settings *settings, PageManager &pageMana } } -int ProgramManager::checkLastUpdate(Settings *settings) +int ProgramManager::checkLastUpdate(Settings *settings, ssize_t *days = nullptr) { - if(settings->updateWarningDays == 0) { + //Wenn die Funktion deaktiviert ist brich ab, wenn nicht nur diffdays verlangt wird + if(settings->updateWarningDays == 0 && !days) { if(settings->debugMode) std::cerr << ">>> Debug In " << __FUNCTION__ << ": In settings: upDateWaring is deaktivated(seted to 0)." << std::endl; return 0; @@ -316,9 +317,15 @@ int ProgramManager::checkLastUpdate(Settings *settings) return 2; } else if( ( ( difDays = static_cast(pageManager.getDate()) - atoll(line.c_str()) )) >= settings->updateWarningDays) { - std::cout << ((settings->colorless) ? "" : "\033[93m") << " => Warnung: SerienListe wurde zuletzt vor " << difDays << " Tagen aktualisiert." - << std::endl << " Mit '" << settings->programName << " search -u' kannst du die Liste aktualisieren." << "\033[0m" << std::endl;; + //Gib nachricht nicht aus wenn nur diffday verlangt wird + if(!days) { + std::cout << ((settings->colorless) ? "" : "\033[93m") << " => Warnung: SerienListe wurde zuletzt vor " << difDays << " Tagen aktualisiert." + << std::endl << " Mit '" << settings->programName << " search -u' kannst du die Liste aktualisieren." << "\033[0m" << std::endl; + } } + //Wenn keine Ausgabe, sondern nur Tage gespeichgtert werden sollen(days != nullptr), speicher diffdays darin + if(days) + *days = difDays; if(settings->debugMode) std::cerr << ">>> Debug In " << __FUNCTION__ << ": Exit with success." << std::endl; @@ -622,7 +629,20 @@ int ProgramManager::directLinkModus(Settings *settings) int ProgramManager::searchModus(Settings *settings, std::string *saveTo, bool noPrint) { - if(settings->search_wantUpdate) { + if(settings->showLastUpdate) { + ssize_t dayddiff; + if(checkLastUpdate(settings, &dayddiff) != 0) { + std::cout << " => Error: CheckLasUpdate-Funktion gab einen Error zurück." << std::endl; + return -1; + } else + std::cout << " => Letzte Aktualisierung: Vor " << dayddiff << " Tagen." << std::endl; + if(!settings->search_wantUpdate && settings->name == "") { + if(settings->debugMode) + std::cout << " >>> Debug: Verlasse Funktion searchModus: Nur -l" << std::endl; + return 0; + } + + } if(settings->search_wantUpdate) { int res = searchModus_update(settings) ; if(res == 0) { std::cout << "Erfolgreich geupdatet: Die Serienliste ist nun auf dem neusten Stand." << std::endl; diff --git a/src/programManager.h b/src/programManager.h index d7c2258..af8d972 100644 --- a/src/programManager.h +++ b/src/programManager.h @@ -58,7 +58,7 @@ private: int searchModus_update(Settings * settings); int waitForThreads(); int sucheNach_1_Serien(Settings *settings, PageManager &pageManager, std::string &newName); - int checkLastUpdate(Settings * settings); + int checkLastUpdate(Settings * settings, ssize_t *days); };