forked from markus/S_New4
v5.1.0
This commit is contained in:
parent
77a94bf532
commit
febfbdcb8b
@ -42,6 +42,8 @@ int setPaths(Settings &settings)
|
|||||||
settings.lastUpdateDateFilePath = CacheDir + "LastUpdateDate";
|
settings.lastUpdateDateFilePath = CacheDir + "LastUpdateDate";
|
||||||
settings.logFilePath = CacheDir + "LogFile";
|
settings.logFilePath = CacheDir + "LogFile";
|
||||||
|
|
||||||
|
settings.lastProgrammUpdateDateFilePath = CacheDir + "LastProgrammUpdateDate";
|
||||||
|
|
||||||
settings.accountFilePath = SettingsDir + "Accounts";
|
settings.accountFilePath = SettingsDir + "Accounts";
|
||||||
settings.serienListPath = SettingsDir + "SerienListe";
|
settings.serienListPath = SettingsDir + "SerienListe";
|
||||||
settings.defaultsFilePath = SettingsDir + "Defaults";
|
settings.defaultsFilePath = SettingsDir + "Defaults";
|
||||||
@ -49,11 +51,15 @@ int setPaths(Settings &settings)
|
|||||||
settings.cacheDir = CacheDir;
|
settings.cacheDir = CacheDir;
|
||||||
settings.configDir = SettingsDir;
|
settings.configDir = SettingsDir;
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int manageParameter(Settings &settings, int argc, char **argv)
|
int manageParameter(Settings &settings, int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
if(argv[0])
|
||||||
|
settings.argv0 = argv[0];
|
||||||
|
|
||||||
//Path settings
|
//Path settings
|
||||||
if(setPaths(settings) != 0) {
|
if(setPaths(settings) != 0) {
|
||||||
if(settings.debugMode)
|
if(settings.debugMode)
|
||||||
@ -210,6 +216,14 @@ int loadDefaulOptions(Settings &settings)
|
|||||||
ofs << "# Wenn deaktiviert, manuelle auswahl der Seiten nötig!" << std::endl;
|
ofs << "# Wenn deaktiviert, manuelle auswahl der Seiten nötig!" << std::endl;
|
||||||
ofs << "#UseFirstPage=true" << std::endl << std::endl;
|
ofs << "#UseFirstPage=true" << std::endl << std::endl;
|
||||||
|
|
||||||
|
ofs << "# -> Mit 0 Können Sie die Warnung für veraltete Suchlisten deaktivieren:" << std::endl;
|
||||||
|
ofs << "#search_UpdateWarnungNachTagen=10" << std::endl << std::endl;
|
||||||
|
|
||||||
|
ofs << "# -> Mit 0 Können Sie die Warnung für nötige Updateüberprüfungen deaktivieren:" << std::endl;
|
||||||
|
ofs << "#search_ProgrammUpdateWarnungNachTagen=10" << std::endl << std::endl;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ofs << "#" << std::endl << "# -> Einstellungen für default Modus:" << std::endl << "#" << std::endl << std::endl;
|
ofs << "#" << std::endl << "# -> Einstellungen für default Modus:" << std::endl << "#" << std::endl << std::endl;
|
||||||
|
|
||||||
ofs << "# -> Standart Wert für Parameter: -g, --genaue-hoster:" << std::endl;
|
ofs << "# -> Standart Wert für Parameter: -g, --genaue-hoster:" << std::endl;
|
||||||
@ -232,8 +246,6 @@ int loadDefaulOptions(Settings &settings)
|
|||||||
ofs << "# -> Standart Wert für Parameter: -e, --exactly-writing:" << std::endl;
|
ofs << "# -> Standart Wert für Parameter: -e, --exactly-writing:" << std::endl;
|
||||||
ofs << "#search-AchteAufGroßUndKleinschreibung=false" << std::endl << std::endl;
|
ofs << "#search-AchteAufGroßUndKleinschreibung=false" << std::endl << std::endl;
|
||||||
|
|
||||||
ofs << "# -> Mit 0 Können Sie die Warnung deaktivieren:" << std::endl;
|
|
||||||
ofs << "#search_UpdateWarnungNachTagen=10" << std::endl << std::endl;
|
|
||||||
|
|
||||||
ofs << "# -> Aktiviert werden bei der Suche sämtliche Namen der Serie angezeigt." << std::endl;
|
ofs << "# -> Aktiviert werden bei der Suche sämtliche Namen der Serie angezeigt." << std::endl;
|
||||||
ofs << "# Bei Animes kann das zu Mehrzeiligen ausgaben pro Serie führen!" << std::endl;
|
ofs << "# Bei Animes kann das zu Mehrzeiligen ausgaben pro Serie führen!" << std::endl;
|
||||||
@ -391,6 +403,16 @@ int loadDefaulOptions(Settings &settings)
|
|||||||
if(settings.debugMode)
|
if(settings.debugMode)
|
||||||
std::cout << " > Defaults: search-showAllNames: " << settings.search_show_othernames << std::endl;
|
std::cout << " > Defaults: search-showAllNames: " << settings.search_show_othernames << std::endl;
|
||||||
|
|
||||||
|
} else if (what == "search_ProgrammUpdateWarnungNachTagen") {
|
||||||
|
if(!isNumber(data)) {
|
||||||
|
std::cout << " Error_Defaults: search_ProgrammUpdateWarnungNachTagen: Wert ist keine Zahl." << std::endl;
|
||||||
|
return 228;
|
||||||
|
} else {
|
||||||
|
settings.programmUpdateWarningDays = atoi(data.c_str());
|
||||||
|
}
|
||||||
|
if(settings.debugMode)
|
||||||
|
std::cout << " > Defaults: search_ProgrammUpdateWarnungNachTagen: " << settings.programmUpdateWarningDays << std::endl;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
std::cout << " => Warnung: Unbekannte Default-Option: '" << what << "'." << std::endl;
|
std::cout << " => Warnung: Unbekannte Default-Option: '" << what << "'." << std::endl;
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,8 @@
|
|||||||
|
|
||||||
#define UpdaterCloudUrlWithPath "https://cloud.obermui.de/s/tXz7SWdaPJ7TacZ/download?path=%2F&files="
|
#define UpdaterCloudUrlWithPath "https://cloud.obermui.de/s/tXz7SWdaPJ7TacZ/download?path=%2F&files="
|
||||||
#define SecondUpdaterCloudUrlWithPath "https://snew4.obermui.de/download?path=%2F&files="
|
#define SecondUpdaterCloudUrlWithPath "https://snew4.obermui.de/download?path=%2F&files="
|
||||||
#define VERSION "5.0.5"
|
#define VERSION "5.1.0"
|
||||||
#define DEFAULT_FILE_VERSION "2.1"
|
#define DEFAULT_FILE_VERSION "2.2"
|
||||||
|
|
||||||
//default, anime, normal,
|
//default, anime, normal,
|
||||||
//suche: für jede katego. eine
|
//suche: für jede katego. eine
|
||||||
@ -122,6 +122,9 @@ struct Settings {
|
|||||||
serienListPath = "",
|
serienListPath = "",
|
||||||
|
|
||||||
lastUpdateDateFilePath = "",
|
lastUpdateDateFilePath = "",
|
||||||
|
lastProgrammUpdateDateFilePath = "",
|
||||||
|
|
||||||
|
|
||||||
configDir="",
|
configDir="",
|
||||||
cacheDir="",
|
cacheDir="",
|
||||||
logFilePath="",
|
logFilePath="",
|
||||||
@ -133,7 +136,8 @@ struct Settings {
|
|||||||
version = VERSION,
|
version = VERSION,
|
||||||
defaultFileVersion= DEFAULT_FILE_VERSION,
|
defaultFileVersion= DEFAULT_FILE_VERSION,
|
||||||
default_checkPath = "",
|
default_checkPath = "",
|
||||||
default_Searchmuster = "S%Staffel%E%Folge%";
|
default_Searchmuster = "S%Staffel%E%Folge%",
|
||||||
|
argv0;
|
||||||
|
|
||||||
std::vector<std::string> outputFilePaths;
|
std::vector<std::string> outputFilePaths;
|
||||||
|
|
||||||
@ -147,13 +151,18 @@ struct Settings {
|
|||||||
askForEveryDir = true,
|
askForEveryDir = true,
|
||||||
skipEpisodenNameOutput = false,
|
skipEpisodenNameOutput = false,
|
||||||
showLastUpdate = false;
|
showLastUpdate = false;
|
||||||
|
|
||||||
int startEpisode = 1,
|
int startEpisode = 1,
|
||||||
stopEpisode = 0,
|
stopEpisode = 0,
|
||||||
startSeason = 1,
|
startSeason = 1,
|
||||||
stopSeason = 0,
|
stopSeason = 0,
|
||||||
proxy_port = 9050,
|
proxy_port = 9050,
|
||||||
default_maxDirs = 20,
|
default_maxDirs = 20,
|
||||||
updateWarningDays = 10;
|
updateWarningDays = 10,
|
||||||
|
|
||||||
|
programmUpdateWarningDays = 20;
|
||||||
|
|
||||||
|
|
||||||
char pathSymbol = '/';
|
char pathSymbol = '/';
|
||||||
char wrongPathSymbol = '\\';
|
char wrongPathSymbol = '\\';
|
||||||
unsigned maxThreads = 0;
|
unsigned maxThreads = 0;
|
||||||
|
@ -21,11 +21,17 @@ int ProgramManager::start(Settings *settings)
|
|||||||
pageManager.setDebugMode(settings->debugMode);
|
pageManager.setDebugMode(settings->debugMode);
|
||||||
pageManager.setProxy(settings->proxy_ip, settings->proxy_port);
|
pageManager.setProxy(settings->proxy_ip, settings->proxy_port);
|
||||||
if(dirExists(settings->cookieFilePath)) {
|
if(dirExists(settings->cookieFilePath)) {
|
||||||
std::cout << " => Error: Kann Cokkie-File nicht erstellen: Es existiert bereits ein Ordner mit diesem Namen: \n '"
|
std::cout << " => Error: Kann Cokkie-File nicht erstellen: \n '"
|
||||||
<< settings->cookieFilePath << "'." << std::endl;
|
<< settings->cookieFilePath << "'." << std::endl;
|
||||||
return 174;
|
return 174;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Überprüfe letzte Update suche
|
||||||
|
if(settings->modus != Modus::UPDATE_MODUS )
|
||||||
|
if( checkLastProgrammUpdate(settings) )
|
||||||
|
return 175;
|
||||||
|
|
||||||
switch (settings->modus) {
|
switch (settings->modus) {
|
||||||
case Modus::DEFAULT_MODUS:
|
case Modus::DEFAULT_MODUS:
|
||||||
return defaultModus(settings);
|
return defaultModus(settings);
|
||||||
@ -186,6 +192,9 @@ int ProgramManager::waitForThreads()
|
|||||||
e->setData(0, 0);
|
e->setData(0, 0);
|
||||||
e->thread = 0;
|
e->thread = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -370,8 +379,88 @@ int ProgramManager::sucheNach_1_Serien(Settings *settings, PageManager &pageMana
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int ProgramManager::checkLastProgrammUpdate(Settings *settings)
|
||||||
|
{
|
||||||
|
//Wenn die Funktion deaktiviert ist brich ab, wenn nicht nur diffdays verlangt wird
|
||||||
|
if(settings->programmUpdateWarningDays == 0) {
|
||||||
|
if(settings->debugMode)
|
||||||
|
std::cerr << ">>> Debug In " << __FUNCTION__ << ": In settings: Programm --- upDateWaring is deaktivated(seted to 0)." << std::endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::ifstream ifs(settings->lastProgrammUpdateDateFilePath);
|
||||||
|
if(!ifs.is_open()) {
|
||||||
|
std::ofstream ofs2(settings->lastProgrammUpdateDateFilePath);
|
||||||
|
if(!ofs2.is_open()) {
|
||||||
|
perror(("Konnte die Datei '" + settings->lastProgrammUpdateDateFilePath + "' nicht öffnen").c_str());
|
||||||
|
if(settings->debugMode)
|
||||||
|
std::cerr << ">>> Debug In " << __FUNCTION__ << ": Failed to create Last Programm Update Date File:'" << settings->lastProgrammUpdateDateFilePath << "'." << std::endl;
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
if(settings->debugMode)
|
||||||
|
std::cerr << ">>> Debug In " << __FUNCTION__ << ": Ordfolgreich Last Programm UpdateTime Save File erstellt:'" << settings->lastProgrammUpdateDateFilePath << "'." << std::endl;
|
||||||
|
ofs2 << "0" << std::endl;
|
||||||
|
ofs2.close();
|
||||||
|
ifs.open(settings->lastProgrammUpdateDateFilePath);
|
||||||
|
if(!ifs.is_open()) {
|
||||||
|
perror(("Konnte die Datei '" + settings->lastProgrammUpdateDateFilePath + "' nicht öffnen").c_str());
|
||||||
|
if(settings->debugMode)
|
||||||
|
std::cerr << ">>> Debug In " << __FUNCTION__ << ": Failed to open Last Programm Update Date File:'" << settings->lastProgrammUpdateDateFilePath << "'." << std::endl;
|
||||||
|
return 4545;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::string line;
|
||||||
|
ssize_t difDays = 0;
|
||||||
|
if(!std::getline(ifs, line).good()) {
|
||||||
|
perror("GetLine from Date failed");
|
||||||
|
if(settings->debugMode)
|
||||||
|
std::cerr << ">>> Debug In " << __FUNCTION__ << ": Get the first Line of the Last Programm UpdateDate File failed." << std::endl;
|
||||||
|
return 2;
|
||||||
|
|
||||||
|
} else if( ( ( difDays = static_cast<long long>(pageManager.getDate()) - atoll(line.c_str()) )) >= settings->programmUpdateWarningDays) {
|
||||||
|
//Gib nachricht nicht aus wenn nur diffday verlangt wird
|
||||||
|
if( true ) {
|
||||||
|
std::cout << ((settings->colorless) ? "" : "\033[93m") << " => Warnung: Eine Überprüfung auf Updates wurde zuletzt vor " << difDays << " Tagen durchgeführt!"
|
||||||
|
<< std::endl << " Wollen sie nach updates suchen? (Y/n): " << ((settings->colorless) ? "" : "\033[0m") << std::flush;
|
||||||
|
std::cin.clear();
|
||||||
|
std::string inp;
|
||||||
|
std::getline(std::cin, inp);
|
||||||
|
|
||||||
|
if(inp == "" || inp == "Y" || inp == "y" || inp == "j" || inp == "J") {
|
||||||
|
std::string program = settings->argv0.substr(0, //ganzer pfad
|
||||||
|
settings->argv0.substr(
|
||||||
|
settings->argv0.find_last_of(settings->pathSymbol) == std::string::npos ? 0 : settings->argv0.find_last_of(settings->pathSymbol)
|
||||||
|
) .find_first_of(" ") );
|
||||||
|
//std::cout << "run: " << program << " --u" << std::endl;
|
||||||
|
if( system(( "\"" + program + "\" --update").c_str()) == 0 ) {
|
||||||
|
std::cout
|
||||||
|
<< std::endl << " -> Wollen sie ihren Befehl mit der alten noch ausführen (oder Programm beenden und neu starten)(Y/n): " << std::flush;
|
||||||
|
|
||||||
|
std::cin.clear();
|
||||||
|
inp = "";
|
||||||
|
std::getline(std::cin, inp);
|
||||||
|
|
||||||
|
if(inp == "" || inp == "Y" || inp == "y" || inp == "j" || inp == "J") {
|
||||||
|
return 0;
|
||||||
|
} else
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
} else if (settings->debugMode)
|
||||||
|
std::cout << "Letzte Update Suche vor " << difDays << " tagen!" << std::endl;
|
||||||
|
|
||||||
|
if(settings->debugMode)
|
||||||
|
std::cerr << ">>> Debug In " << __FUNCTION__ << ": Exit with success." << std::endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int ProgramManager::checkLastUpdate(Settings *settings, ssize_t *days = nullptr)
|
int ProgramManager::checkLastUpdate(Settings *settings, ssize_t *days = nullptr)
|
||||||
{
|
{
|
||||||
|
|
||||||
//Wenn die Funktion deaktiviert ist brich ab, wenn nicht nur diffdays verlangt wird
|
//Wenn die Funktion deaktiviert ist brich ab, wenn nicht nur diffdays verlangt wird
|
||||||
if(settings->updateWarningDays == 0 && !days) {
|
if(settings->updateWarningDays == 0 && !days) {
|
||||||
if(settings->debugMode)
|
if(settings->debugMode)
|
||||||
@ -1362,16 +1451,42 @@ int ProgramManager::updateModus(Settings *settings)
|
|||||||
|
|
||||||
//Vergleiche Versionen:
|
//Vergleiche Versionen:
|
||||||
switch (pageManager.compareVersions(settings->version, neusteVersion)) {
|
switch (pageManager.compareVersions(settings->version, neusteVersion)) {
|
||||||
case 0:
|
case 0: {
|
||||||
std::cout << "\n => Du benützt bereits die neuste Release-Version." << std::endl;
|
std::cout << "\n => Du benützt bereits die neuste Release-Version." << std::endl;
|
||||||
|
|
||||||
|
//Speicher Datum des Updates...
|
||||||
|
std::ofstream ofs;
|
||||||
|
ofs.open(settings->lastProgrammUpdateDateFilePath, std::ios::trunc);
|
||||||
|
if(!ofs.is_open()) {
|
||||||
|
perror("Konnte UpdateDate-Datei nicht öffnen");
|
||||||
|
return 113;
|
||||||
|
} else {
|
||||||
|
//Schreibe Liste in das TextFile
|
||||||
|
ofs << pageManager.getDate() << std::endl;
|
||||||
|
ofs.close();
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
case 1:
|
} case 1:
|
||||||
//Diese Version ist klleienr als aktuelle Version => Updatete
|
//Diese Version ist klleienr als aktuelle Version => Updatete
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2: {
|
||||||
std::cout << "\n => Du benützt bereits eine Aktuellere Version als die neuste Release-Version." << std::endl;
|
std::cout << "\n => Du benützt bereits eine Aktuellere Version als die neuste Release-Version." << std::endl;
|
||||||
|
|
||||||
|
//Speicher Datum des Updates...
|
||||||
|
std::ofstream ofs;
|
||||||
|
ofs.open(settings->lastProgrammUpdateDateFilePath, std::ios::trunc);
|
||||||
|
if(!ofs.is_open()) {
|
||||||
|
perror("Konnte UpdateDate-Datei nicht öffnen");
|
||||||
|
return 113;
|
||||||
|
} else {
|
||||||
|
//Schreibe Liste in das TextFile
|
||||||
|
ofs << pageManager.getDate() << std::endl;
|
||||||
|
ofs.close();
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
default:
|
} default:
|
||||||
//Error
|
//Error
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
@ -1519,6 +1634,18 @@ int ProgramManager::updateModus(Settings *settings)
|
|||||||
std::cout << ((settings->colorless) ? ("") : "\033[92m") << "\n => Update Erfolgreich ausgeführt: '" << settings->version <<
|
std::cout << ((settings->colorless) ? ("") : "\033[92m") << "\n => Update Erfolgreich ausgeführt: '" << settings->version <<
|
||||||
"' -> '" << neusteVersion << "'" << ((settings->colorless) ? ("") : "\033[0m") << std::endl;
|
"' -> '" << neusteVersion << "'" << ((settings->colorless) ? ("") : "\033[0m") << std::endl;
|
||||||
|
|
||||||
|
//Speicher Datum des Updates...
|
||||||
|
std::ofstream ofs;
|
||||||
|
ofs.open(settings->lastProgrammUpdateDateFilePath, std::ios::trunc);
|
||||||
|
if(!ofs.is_open()) {
|
||||||
|
perror("Konnte UpdateDate-Datei nicht öffnen");
|
||||||
|
return 113;
|
||||||
|
} else {
|
||||||
|
//Schreibe Liste in das TextFile
|
||||||
|
ofs << pageManager.getDate() << std::endl;
|
||||||
|
ofs.close();
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,6 +62,8 @@ private:
|
|||||||
int sucheNach_1_Serien(Settings *settings, PageManager &pageManager, checkNameRply &newNameAndPage);
|
int sucheNach_1_Serien(Settings *settings, PageManager &pageManager, checkNameRply &newNameAndPage);
|
||||||
int checkLastUpdate(Settings * settings, ssize_t *days);
|
int checkLastUpdate(Settings * settings, ssize_t *days);
|
||||||
|
|
||||||
|
int checkLastProgrammUpdate(Settings *settings);
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user