forked from markus/S_New4
v3.7.0: add paramater to search: -l: print last update
This commit is contained in:
parent
c16e88c2f0
commit
4237493dc2
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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<long long>(pageManager.getDate()) - atoll(line.c_str()) )) >= settings->updateWarningDays) {
|
||||
//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;;
|
||||
<< 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;
|
||||
|
@ -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);
|
||||
|
||||
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user