forked from markus/S_New4
v2.9.0 add info new and deleted serien when update searchlist with colormode
This commit is contained in:
parent
1eed669a8f
commit
61772afeb8
@ -47,7 +47,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 = "2.8.3",
|
version = "2.9.0",
|
||||||
defaultFileVersion="1.3",
|
defaultFileVersion="1.3",
|
||||||
outputFilePath = "",
|
outputFilePath = "",
|
||||||
default_checkPath = "",
|
default_checkPath = "",
|
||||||
|
@ -744,47 +744,51 @@ int ProgramManager::searchModus_update(Settings *settings)
|
|||||||
//Anzahl der Serien/Zeilen vorher:
|
//Anzahl der Serien/Zeilen vorher:
|
||||||
ssize_t countBef = 0;
|
ssize_t countBef = 0;
|
||||||
std::ifstream myFileBef(settings->serienListPath);
|
std::ifstream myFileBef(settings->serienListPath);
|
||||||
if(myFileBef.is_open())
|
std::string alteListe;
|
||||||
for(countBef = 0; std::getline(myFileBef,line); ++countBef);
|
if(myFileBef.is_open()) {
|
||||||
myFileBef.close();
|
for(countBef = 0; std::getline(myFileBef,line); ++countBef) {
|
||||||
|
//Speicher alteListe für verglkeich nach Update
|
||||||
|
alteListe.append(line + "\n");
|
||||||
|
|
||||||
//Speicher für Vergleich Alte liste:
|
//Vergeliche neue und alte list => entfernte Serien
|
||||||
std::ifstream t(settings->serienListPath);
|
if(line != "" && serienListe.find(line) == std::string::npos) {
|
||||||
if(!t.is_open()) {
|
std::cout << ((settings->colorless) ? "" : "\033[91m") << "Entfernt: '" << line.substr(line.find_last_of("|") + 1) << "'" << "\033[0m" << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
myFileBef.close();
|
||||||
|
} else {
|
||||||
perror("Konnte SerienListe-Datei nicht öffnen");
|
perror("Konnte SerienListe-Datei nicht öffnen");
|
||||||
return 110;
|
return 110;
|
||||||
}
|
}
|
||||||
std::string alte_list((std::istreambuf_iterator<char>(t)),
|
|
||||||
std::istreambuf_iterator<char>());
|
|
||||||
t.close();
|
|
||||||
|
|
||||||
//Schreibe die Liste in das TextFile
|
//Schreibe die Liste in das TextFile
|
||||||
std::ofstream ofs(settings->serienListPath, std::ios::trunc);
|
std::ofstream ofs(settings->serienListPath, std::ios::trunc);
|
||||||
if(!ofs.is_open()) {
|
if(!ofs.is_open()) {
|
||||||
perror("Konnte SerienListe-Datei nicht öffnen");
|
perror("Konnte SerienListe-Datei nicht öffnen");
|
||||||
return 111;
|
return 111;
|
||||||
}
|
} else {
|
||||||
|
//Schreibe Liste in das TextFile
|
||||||
ofs << serienListe << std::endl;
|
ofs << serienListe << std::endl;
|
||||||
ofs.close();
|
ofs.close();
|
||||||
|
}
|
||||||
|
|
||||||
//Anzahl der Zeile nachher
|
//Anzahl der Zeile nachher
|
||||||
ssize_t countAf = 0;
|
ssize_t countAf = 0;
|
||||||
std::ifstream myFileAf(settings->serienListPath);
|
std::ifstream myFileAf(settings->serienListPath);
|
||||||
if(myFileAf.is_open())
|
if(myFileAf.is_open()) {
|
||||||
for(countAf = 0; std::getline(myFileAf,line); ++countAf);
|
for(countAf = 0; std::getline(myFileAf,line); ++countAf) {
|
||||||
|
//Vergeliche neu mit Alt => gib neue Serien aus
|
||||||
|
if(line != "" && alteListe.find(line) == std::string::npos) {
|
||||||
|
std::cout << ((settings->colorless) ? "" : "\033[92m") << "Neu: '" << line.substr(line.find_last_of("|") + 1) << "'" << "\033[0m" << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
myFileAf.close();
|
myFileAf.close();
|
||||||
|
} else {
|
||||||
|
perror("Konnte SerienListe-Datei nicht öffnen");
|
||||||
//Vergleiche alte/Neue Liste:
|
return 112;
|
||||||
|
|
||||||
std::stringstream newStrStr(serienListe.c_str());
|
|
||||||
while (std::getline(newStrStr, line).good()) {
|
|
||||||
if(line != "" && alte_list.find(line) == std::string::npos) {
|
|
||||||
std::cout << "Neu: '" << line.substr(line.find_last_of("|") + 1) << "'" << std::endl;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "Serienunterschied: " << ( ((countAf - countBef) > 0) ? "+" : "") << countAf - countBef << " Serien." << std::endl;
|
std::cout << ((settings->colorless) ? "" : "\033[93m") << "Serienunterschied: " << ( ((countAf - countBef) > 0) ? "+" : "") << countAf - countBef << " Serien." << "\033[0m" << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user