v3.7.0: add paramater to search: -l: print last update

This commit is contained in:
Markus 2019-11-11 19:01:15 +01:00
parent c16e88c2f0
commit 4237493dc2
4 changed files with 41 additions and 11 deletions

View File

@ -775,12 +775,13 @@ int unterOption_search(Settings *settings, int argc, char **argv)
{"debug-mode", no_argument, nullptr, 'd'}, {"debug-mode", no_argument, nullptr, 'd'},
{"exactly-writing", no_argument, nullptr, 'e'}, {"exactly-writing", no_argument, nullptr, 'e'},
{"update", no_argument, nullptr, 'u'}, {"update", no_argument, nullptr, 'u'},
{"last-update", no_argument, nullptr, 'l'},


{nullptr, no_argument, nullptr, 0} {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) { switch(c) {
case 'p': case 'p':
if(!optarg || setS5ProxytoSettings(*settings, optarg) != 0) if(!optarg || setS5ProxytoSettings(*settings, optarg) != 0)
@ -809,6 +810,11 @@ int unterOption_search(Settings *settings, int argc, char **argv)
if(settings->debugMode) if(settings->debugMode)
std::cout << "Update die Liste: true" << std::endl; std::cout << "Update die Liste: true" << std::endl;
break; break;
case 'l':
settings->showLastUpdate = true;
if(settings->debugMode)
std::cout << "showLastUpdate: true" << std::endl;
break;
default: default:
std::cout << "Aufruf: " << settings->programName << " search [OPTION]... [NAME]..." << std::endl; std::cout << "Aufruf: " << settings->programName << " search [OPTION]... [NAME]..." << std::endl;
std::cout << "\"" << settings->programName << " search --help\" liefert weitere Informationen." << 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) void unterOption_search_help(std::string programName)
{ {
std::cout << "Aufruf: " << programName << " search [OPTION]... [NAME]" << std::endl std::cout << "Aufruf: " << programName << " search [OPTION]... [NAME]" << std::endl
<< " " << programName << " search [-u, --update] [OPTION]... [NAME]" << std::endl << " " << programName << " search [OPTION]... [{-u, --update}&|/{-l, --last-update}]" << std::endl
<< " " << programName << " search [-u, --update]" << std::endl << std::endl; << " " << programName << " search [OPTION]... [{-u, --update}&|/{-l, --last-update}] [Name]" << std::endl << std::endl;


std::cout << "Beschreibung:" << std::endl std::cout << "Beschreibung:" << std::endl
<< " Mit dieser Unterfunktion des Programms kann man Serien auf s.to suchen." << 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 << " Standart: 127.0.0.1:9050 - Port 0 um Proxy zu deaktivieren." << std::endl << std::endl
<< " -e, --exactly-writing" << std::endl << " -e, --exactly-writing" << std::endl
<< " Mit dieser Option achtet das Programm auf Groß- und Kleinschreibung." << std::endl << 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 << " -c, --colorless" << std::endl
<< " Mit dieser Option kann man die farbige Ausgabe ausstellen." << std::endl << std::endl << " Mit dieser Option kann man die farbige Ausgabe ausstellen." << std::endl << std::endl
<< " -d, --debug-mode" << std::endl << " -d, --debug-mode" << std::endl

View File

@ -81,7 +81,7 @@ struct Settings {
proxy_ip = "127.0.0.1", proxy_ip = "127.0.0.1",
languages = "GerDub,GerSub,Eng,", languages = "GerDub,GerSub,Eng,",
genaueHoster = "", genaueHoster = "",
version = "3.6.3", version = "3.7.0",
defaultFileVersion="1.6", defaultFileVersion="1.6",
outputFilePath = "", outputFilePath = "",
default_checkPath = "", default_checkPath = "",
@ -93,7 +93,8 @@ struct Settings {
search_IgnoreUpperLower = true, search_IgnoreUpperLower = true,
search_wantUpdate = false, search_wantUpdate = false,
askForEveryDir = true, askForEveryDir = true,
skipEpisodenNameOutput = false; skipEpisodenNameOutput = false,
showLastUpdate = false;
int startEpisode = 1, int startEpisode = 1,
stopEpisode = 0, stopEpisode = 0,
startSeason = 1, startSeason = 1,

View File

@ -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) if(settings->debugMode)
std::cerr << ">>> Debug In " << __FUNCTION__ << ": In settings: upDateWaring is deaktivated(seted to 0)." << std::endl; std::cerr << ">>> Debug In " << __FUNCTION__ << ": In settings: upDateWaring is deaktivated(seted to 0)." << std::endl;
return 0; return 0;
@ -316,9 +317,15 @@ int ProgramManager::checkLastUpdate(Settings *settings)
return 2; return 2;


} else if( ( ( difDays = static_cast<long long>(pageManager.getDate()) - atoll(line.c_str()) )) >= settings->updateWarningDays) { } else if( ( ( difDays = static_cast<long long>(pageManager.getDate()) - atoll(line.c_str()) )) >= settings->updateWarningDays) {
std::cout << ((settings->colorless) ? "" : "\033[93m") << " => Warnung: SerienListe wurde zuletzt vor " << difDays << " Tagen aktualisiert." //Gib nachricht nicht aus wenn nur diffday verlangt wird
<< std::endl << " Mit '" << settings->programName << " search -u' kannst du die Liste aktualisieren." << "\033[0m" << std::endl;; 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) if(settings->debugMode)
std::cerr << ">>> Debug In " << __FUNCTION__ << ": Exit with success." << std::endl; 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) 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) ; int res = searchModus_update(settings) ;
if(res == 0) { if(res == 0) {
std::cout << "Erfolgreich geupdatet: Die Serienliste ist nun auf dem neusten Stand." << std::endl; std::cout << "Erfolgreich geupdatet: Die Serienliste ist nun auf dem neusten Stand." << std::endl;

View File

@ -58,7 +58,7 @@ private:
int searchModus_update(Settings * settings); int searchModus_update(Settings * settings);
int waitForThreads(); int waitForThreads();
int sucheNach_1_Serien(Settings *settings, PageManager &pageManager, std::string &newName); int sucheNach_1_Serien(Settings *settings, PageManager &pageManager, std::string &newName);
int checkLastUpdate(Settings * settings); int checkLastUpdate(Settings * settings, ssize_t *days);




}; };