forked from markus/S_New4
mach suchFunktion inc. Suchappdater multipageable
This commit is contained in:
parent
b46a966cda
commit
9602da29e7
@ -290,24 +290,45 @@ std::string PageManager::getUrlAfterRedirect(std::string Url)
|
|||||||
return getServerRequest(Url, true, "", false, true).url;
|
return getServerRequest(Url, true, "", false, true).url;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string PageManager::checkName(std::string Name)
|
std::string PageManager::checkName(std::vector<PAGE> pages, std::string Name)
|
||||||
{
|
{
|
||||||
|
int count = 0;
|
||||||
std::string name = replace(Name, " ", "-");
|
std::string name = replace(Name, " ", "-");
|
||||||
|
std::string pagesonExist;
|
||||||
|
|
||||||
std::string html = getServerRequest("https://serienstream.sx/serie/stream/" + name).html;
|
//für jede Seite
|
||||||
if(html.find("Die gewünschte Serie wurde nicht gefunden oder ist im Moment deaktiviert.") != std::string::npos) {
|
for ( const auto &page : pages ) {
|
||||||
std::cout << "\33[2K\r => Die gewünschte Serie wurde nicht gefunden oder ist im Moment deaktiviert: '" << Name << "'" << std::endl;
|
|
||||||
return "-1";
|
std::string html = getServerRequest("https://" + page.url +"/serie/stream/" + name).html;
|
||||||
} else if (html.find("404 - Seite nicht gefunden") != std::string::npos) {
|
if(html.find("Die gewünschte Serie wurde nicht gefunden oder ist im Moment deaktiviert.") != std::string::npos) {
|
||||||
std::cout << "\33[2K\r => Ungültiger Name: '" << Name << "'" << std::endl;
|
continue;
|
||||||
return "-1";
|
|
||||||
} else if (html == "-1" || html == "") {
|
} else if (html.find("404 - Seite nicht gefunden") != std::string::npos) {
|
||||||
return "-2";
|
std::cout << "\33[2K\r => Ungültiger Name: '" << Name << "'" << std::endl;
|
||||||
|
return "-1";
|
||||||
|
|
||||||
|
} else if (html == "-1" || html == "") {
|
||||||
|
return "-2";
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
count ++;
|
||||||
|
pagesonExist += page.url + " ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
|
//
|
||||||
|
if( count == 1 ) {
|
||||||
std::cout << "\33[2K\r > Name: " << name << std::endl;
|
std::cout << "\33[2K\r > Name: " << name << std::endl;
|
||||||
return name;
|
return name;
|
||||||
|
} else if ( count > 1) {
|
||||||
|
std::cout << "\33[2K\r => Die Serie existiert auf mehreren Seiten " << pagesonExist << ": '" << name << "'" << std::endl;
|
||||||
|
return "-1";
|
||||||
|
} else {
|
||||||
|
std::cout << "\33[2K\r => Die gewünschte Serie wurde nicht gefunden oder ist im Moment deaktiviert: '" << Name << "'" << std::endl;
|
||||||
|
return "-1";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string PageManager::getLinks(std::string HTML)
|
std::string PageManager::getLinks(std::string HTML)
|
||||||
|
@ -37,7 +37,7 @@ public:
|
|||||||
|
|
||||||
int login(Account account);
|
int login(Account account);
|
||||||
std::string getUrlAfterRedirect(std::string Url);
|
std::string getUrlAfterRedirect(std::string Url);
|
||||||
std::string checkName(std::string Name);
|
std::string checkName(std::vector<PAGE> pages, std::string Name);
|
||||||
std::string getLinks(std::string HTML);
|
std::string getLinks(std::string HTML);
|
||||||
std::string chooseHosterLink(std::string HosterList, std::string Hoster_with_Highst_Priority_at_First, std::string languages_with_highst_priority_at_first, bool withWarnMsg);
|
std::string chooseHosterLink(std::string HosterList, std::string Hoster_with_Highst_Priority_at_First, std::string languages_with_highst_priority_at_first, bool withWarnMsg);
|
||||||
std::string getLinkAfterHosterBasedOperation(std::string url);
|
std::string getLinkAfterHosterBasedOperation(std::string url);
|
||||||
|
@ -30,6 +30,10 @@
|
|||||||
#define VERSION "4.3.7"
|
#define VERSION "4.3.7"
|
||||||
|
|
||||||
|
|
||||||
|
//default, anime, normal,
|
||||||
|
//suche: für jede katego. eine
|
||||||
|
//zu beginn, erst eiunmal serie suchen
|
||||||
|
|
||||||
|
|
||||||
enum Modus {
|
enum Modus {
|
||||||
EXIT = -1,
|
EXIT = -1,
|
||||||
@ -44,9 +48,38 @@ enum Modus {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct PAGE {
|
||||||
|
PAGE( std::string url, std::string nameID )
|
||||||
|
: name_id(nameID), url(url) {}
|
||||||
|
|
||||||
|
std::string name_id,
|
||||||
|
url;
|
||||||
|
std::string urlAlphabetSerienList,
|
||||||
|
UrlDir;
|
||||||
|
|
||||||
|
|
||||||
|
std::string accountFileName = "",
|
||||||
|
accountNumberFileName= "",
|
||||||
|
cookieFileName = "",
|
||||||
|
serienListName = "";
|
||||||
|
};
|
||||||
|
|
||||||
struct Settings {
|
struct Settings {
|
||||||
Settings() {}
|
Settings() {
|
||||||
Settings(std::string name) : name(name) {}
|
PAGE sto( "serienstream.sx", "Normale_Serien");
|
||||||
|
sto.urlAlphabetSerienList = "/serien-alphabet";
|
||||||
|
sto.UrlDir = "/serie/stream/";
|
||||||
|
|
||||||
|
pages.push_back( sto );
|
||||||
|
|
||||||
|
PAGE anicio ( "anicloud.io", "Animes");
|
||||||
|
anicio.urlAlphabetSerienList = "/animes-alphabet";
|
||||||
|
anicio.UrlDir = "/anime/stream/";
|
||||||
|
|
||||||
|
pages.push_back( anicio );
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
const std::string programName = "S_New4";
|
const std::string programName = "S_New4";
|
||||||
|
|
||||||
// Wenn das Betriebsystem x86 ist:
|
// Wenn das Betriebsystem x86 ist:
|
||||||
@ -81,11 +114,13 @@ struct Settings {
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
std::vector<PAGE> pages;
|
||||||
std::string name,
|
std::string name,
|
||||||
accountFilePath = "",
|
accountFilePath = "",
|
||||||
accountNumberPath= "",
|
accountNumberPath= "",
|
||||||
cookieFilePath = "",
|
cookieFilePath = "",
|
||||||
serienListPath = "",
|
serienListPath = "",
|
||||||
|
|
||||||
lastUpdateDateFilePath = "",
|
lastUpdateDateFilePath = "",
|
||||||
configDir="",
|
configDir="",
|
||||||
cacheDir="",
|
cacheDir="",
|
||||||
@ -102,6 +137,7 @@ struct Settings {
|
|||||||
|
|
||||||
std::vector<std::string> outputFilePaths;
|
std::vector<std::string> outputFilePaths;
|
||||||
|
|
||||||
|
|
||||||
Modus modus = Modus::EXIT;
|
Modus modus = Modus::EXIT;
|
||||||
bool colorless = false,
|
bool colorless = false,
|
||||||
debugMode = false,
|
debugMode = false,
|
||||||
|
@ -288,7 +288,7 @@ int ProgramManager::sucheNach_1_Serien(Settings *settings, PageManager &pageMana
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Überprüfe ob es die serie gibt wenn ja speicher ihn in newname und beende Function
|
//Überprüfe ob es die serie gibt wenn ja speicher ihn in newname und beende Function
|
||||||
newName = pageManager.checkName(finds);
|
//<>/newName = pageManager.checkName(finds);
|
||||||
if(newName == "-2")
|
if(newName == "-2")
|
||||||
return 23;
|
return 23;
|
||||||
else if( newName == "-1" ) {
|
else if( newName == "-1" ) {
|
||||||
@ -391,8 +391,10 @@ int ProgramManager::defaultModus(Settings *settings)
|
|||||||
if(dirFiles.length() > 0) //Entferne von der liste das \n am ende
|
if(dirFiles.length() > 0) //Entferne von der liste das \n am ende
|
||||||
dirFiles.pop_back();
|
dirFiles.pop_back();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Führe Function aus, die überprüft ob die serie existiert
|
//Führe Function aus, die überprüft ob die serie existiert
|
||||||
std::string nameInUrl =pageManager.checkName(settings->name);
|
std::string nameInUrl =pageManager.checkName(settings->pages, settings->name);
|
||||||
if(nameInUrl == "-2")
|
if(nameInUrl == "-2")
|
||||||
return 67;
|
return 67;
|
||||||
else if(nameInUrl == "-1") {
|
else if(nameInUrl == "-1") {
|
||||||
@ -684,6 +686,14 @@ int ProgramManager::searchModus(Settings *settings, std::string *saveTo, bool no
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Check for last Update.. (glaub hier nocghmal die funktion, um datei zu erstellen, auch wenn ausgabe deaktiviert is, kann aber auch sein dass der teil ghier weg gehört)
|
||||||
|
if(checkLastUpdate(settings) != 0) {
|
||||||
|
if(settings->debugMode)
|
||||||
|
std::cerr << ">>> Debug In " << __FUNCTION__ << ": checkLastUpdate function failed." << std::endl;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
std::ifstream ifs(settings->serienListPath);
|
std::ifstream ifs(settings->serienListPath);
|
||||||
if(!ifs.is_open()) {
|
if(!ifs.is_open()) {
|
||||||
std::cout << " => Keine SerienListe vorhanden. Erstelle eine neue..." << std::endl;
|
std::cout << " => Keine SerienListe vorhanden. Erstelle eine neue..." << std::endl;
|
||||||
@ -702,15 +712,9 @@ int ProgramManager::searchModus(Settings *settings, std::string *saveTo, bool no
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check for last Update..
|
|
||||||
if(checkLastUpdate(settings) != 0) {
|
|
||||||
if(settings->debugMode)
|
|
||||||
std::cerr << ">>> Debug In " << __FUNCTION__ << ": checkLastUpdate function failed." << std::endl;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Save file in string:
|
//Save file in string:
|
||||||
std::string serienListe((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>());
|
std::string serienListe = std::string((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>());
|
||||||
|
|
||||||
//Suche alle Möglichkeiten
|
//Suche alle Möglichkeiten
|
||||||
std::string finds = pageManager.grep(serienListe, settings->name, settings->search_IgnoreUpperLower);
|
std::string finds = pageManager.grep(serienListe, settings->name, settings->search_IgnoreUpperLower);
|
||||||
@ -749,11 +753,35 @@ int ProgramManager::searchModus(Settings *settings, std::string *saveTo, bool no
|
|||||||
std::stringstream strstream(finds);
|
std::stringstream strstream(finds);
|
||||||
std::string line;
|
std::string line;
|
||||||
std::cout << " => Für '" << settings->name << "' wurde(n) folgende Serie(n) gefunden: " << std::endl;
|
std::cout << " => Für '" << settings->name << "' wurde(n) folgende Serie(n) gefunden: " << std::endl;
|
||||||
|
|
||||||
|
std::string lastPageUrl;
|
||||||
while (getline(strstream, line)) {
|
while (getline(strstream, line)) {
|
||||||
std::cout << " > " << line.substr(line.find_last_of('|') + 1, std::string::npos )
|
|
||||||
<< "\t[" << line.substr(line.find("|/") + 2, line.find("|", line.find("|/") + 2) - line.find("|/") - 2) << "]"
|
//splitting
|
||||||
<< ( (line[0] == '|') ? "" : "\t( " + line.substr(0, line.find("|")) + " )" ) << std::endl;
|
///Nadia The Secret, Fushigi no Nadia|/nadia-zauberstein|Nadia und Zauberstein|seriento
|
||||||
}
|
// into Vector
|
||||||
|
|
||||||
|
std::vector<std::string> parts;
|
||||||
|
std::istringstream f(line + "|");
|
||||||
|
std::string p;
|
||||||
|
while (getline(f, p, '|').good())
|
||||||
|
parts.push_back(p);
|
||||||
|
if(parts.size() != 4) {
|
||||||
|
std::cout << " => Error: Invalid SerienListeEintrag: '" << line << "'" << parts.size() << std::endl;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( lastPageUrl != parts.at(3) ) {
|
||||||
|
std::cout << ((settings->colorless) ? "" : "\033[93m") << "Auf '" << parts.at(3) << "'..." << ((settings->colorless) ? "" : "\033[0m") << std::endl;
|
||||||
|
lastPageUrl = parts.at(3);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << " > " << parts.at(2) << "\t[" << parts.at(1).erase(0, 1) << "]"
|
||||||
|
<< ( (line[0] == '|') ? "" : "\t( " + parts.at(0) + " )" ) << std::endl;
|
||||||
|
|
||||||
|
///That Time I Got Reincarnated as a Slime|/tensei-shitara-slime-datta-ken|Tensei Shitara Slime Datta Ken|ANIME
|
||||||
|
} /// > Tensei Shitara Slime Datta Ken [tensei-shitara-slime-datta-ken] ( That Time I Got Reincarnated as a Slime ) <s.to>
|
||||||
|
|
||||||
if(settings->debugMode)
|
if(settings->debugMode)
|
||||||
std::cerr << ">>> Debug In " << __FUNCTION__ << ": success." << std::endl;
|
std::cerr << ">>> Debug In " << __FUNCTION__ << ": success." << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
@ -769,7 +797,7 @@ int ProgramManager::infoModus(Settings *settings)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Führe Function aus, die überprüft ob die serie existiert
|
//Führe Function aus, die überprüft ob die serie existiert
|
||||||
std::string nameInUrl = pageManager.checkName(settings->name);
|
std::string nameInUrl;//<>/ = pageManager.checkName(settings->name);
|
||||||
if(nameInUrl == "-2")
|
if(nameInUrl == "-2")
|
||||||
return 145;
|
return 145;
|
||||||
else if(nameInUrl == "-1") {
|
else if(nameInUrl == "-1") {
|
||||||
@ -1361,82 +1389,91 @@ int ProgramManager::cleanUpSettingsAndCache(Settings *settings)
|
|||||||
|
|
||||||
int ProgramManager::searchModus_update(Settings *settings)
|
int ProgramManager::searchModus_update(Settings *settings)
|
||||||
{
|
{
|
||||||
Reply reply = pageManager.getServerRequest("https://serienstream.sx/serien-alphabet");
|
std::string list;
|
||||||
if(reply.html == "-1") {
|
|
||||||
if(settings->debugMode)
|
|
||||||
std::cerr << ">>> Debug In " << __FUNCTION__ << ": getServerRequest function failed." << std::endl;
|
|
||||||
return 21;
|
|
||||||
}
|
|
||||||
else if(reply.html.find("</html>") == std::string::npos ) {
|
|
||||||
std::cout << " => Error: Konnte </html> in searchModus_update() nicht finden." << std::endl;
|
|
||||||
return 22;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string serienListe = replace( pageManager.grep( reply.html, "data-alternative-title" ), "</li>", "\n" );
|
|
||||||
|
|
||||||
std::string tests[] = {"\" href=\"", "<li><a data-alternative-title=\"", "/serie/stream/", "</a>", };
|
|
||||||
for ( auto t : tests ) {
|
|
||||||
if(reply.html.find( t ) == std::string::npos) {
|
|
||||||
if(settings->debugMode)
|
|
||||||
std::cerr << ">>> Debug In " << __FUNCTION__ << ": hatml doesnt contain:'" << t << "' after preparing." << std::endl;
|
|
||||||
return 51;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//...\n<li><a data-alternative-title="" href="/serie/stream/2012-das-jahr-null" title="2012 - Das Jahr Null Stream anschauen">2012 - Das Jahr Null</a>\n...
|
|
||||||
serienListe = replace(serienListe, "<li><a data-alternative-title=\"", "");
|
|
||||||
//...\n" href="/serie/stream/2012-das-jahr-null" title="2012 - Das Jahr Null Stream anschauen">2012 - Das Jahr Null</a>\n...
|
|
||||||
serienListe = replace(serienListe, "\" href=\"", "|");
|
|
||||||
//...\n|/serie/stream/2012-das-jahr-null" title="2012 - Das Jahr Null Stream anschauen">2012 - Das Jahr Null</a>\n...
|
|
||||||
serienListe = replace(serienListe, "|/serie/stream/", "|/");
|
|
||||||
|
|
||||||
std::stringstream strstream(serienListe);
|
|
||||||
std::string line;
|
std::string line;
|
||||||
serienListe.clear();
|
|
||||||
|
|
||||||
while (getline(strstream, line)) {
|
for ( const auto &page : settings->pages ) {
|
||||||
if(line.find(" title=\"") == std::string::npos)
|
std::cout << " -> Updating '" << page.name_id << "'..." << std::endl;
|
||||||
continue;
|
|
||||||
|
|
||||||
line.erase(line.find(" title="), line.find(">") - line.find(" title="));
|
Reply reply = pageManager.getServerRequest("https://" + page.url + page.urlAlphabetSerienList);
|
||||||
//...\n|/serie/stream/2012-das-jahr-null"_weg_>2012 - Das Jahr Null</a>\n...
|
|
||||||
line = replace(line, "\">", "|");
|
|
||||||
//...\n|/serie/stream/2012-das-jahr-null|2012 - Das Jahr Null</a>\n...
|
if(reply.html == "-1") {
|
||||||
line = replace(line, "</a>", "");
|
if(settings->debugMode)
|
||||||
//...\n|/serie/stream/2012-das-jahr-null"_weg_>2012 - Das Jahr Null|\n...
|
std::cerr << ">>> Debug In " << __FUNCTION__ << ": getServerRequest function failed." << std::endl;
|
||||||
|
return 21;
|
||||||
|
}
|
||||||
|
else if(reply.html.find("</html>") == std::string::npos ) {
|
||||||
|
std::cout << " => Error: Konnte </html> in searchModus_update() nicht finden." << std::endl;
|
||||||
|
return 22;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string serienListe = replace( pageManager.grep( reply.html, "data-alternative-title" ), "</li>", "\n" );
|
||||||
|
|
||||||
|
std::string tests[] = {"\" href=\"", "<li><a data-alternative-title=\"", page.UrlDir, "</a>", };
|
||||||
|
for ( auto t : tests ) {
|
||||||
|
if(reply.html.find( t ) == std::string::npos) {
|
||||||
|
if(settings->debugMode)
|
||||||
|
std::cerr << ">>> Debug In " << __FUNCTION__ << ": hatml doesnt contain:'" << t << "' after preparing." << std::endl;
|
||||||
|
return 51;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//...\n<li><a data-alternative-title="" href="/serie /stream/2012-das-jahr-null" title="2012 - Das Jahr Null Stream anschauen">2012 - Das Jahr Null</a>\n...
|
||||||
|
serienListe = replace(serienListe, "<li><a data-alternative-title=\"", "");
|
||||||
|
//...\n" href="/serie /stream/2012-das-jahr-null" title="2012 - Das Jahr Null Stream anschauen">2012 - Das Jahr Null</a>\n...
|
||||||
|
serienListe = replace(serienListe, "\" href=\"", "|");
|
||||||
|
//...\n|/serie /stream/2012-das-jahr-null" title="2012 - Das Jahr Null Stream anschauen">2012 - Das Jahr Null</a>\n...
|
||||||
|
serienListe = replace(serienListe, "|" + page.UrlDir, "|/");
|
||||||
|
|
||||||
|
std::stringstream strstream(serienListe);
|
||||||
|
serienListe.clear();
|
||||||
|
|
||||||
|
while (getline(strstream, line)) {
|
||||||
|
if(line.find(" title=\"") == std::string::npos)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
line.erase(line.find(" title="), line.find(">") - line.find(" title="));
|
||||||
|
//...\n|/serie/ stream/2012-das-jahr-null"_weg_>2012 - Das Jahr Null</a>\n...
|
||||||
|
line = replace(line, "\">", "|");
|
||||||
|
//...\n|/serie/ stream/2012-das-jahr-null|2012 - Das Jahr Null</a>\n...
|
||||||
|
line = replace(line, "</a>", "");
|
||||||
|
//...\n|/serie/ stream/2012-das-jahr-null"_weg_>2012 - Das Jahr Null|\n...
|
||||||
|
|
||||||
|
///Nadia The Secret, Fushigi no Nadia|/nadia-zauberstein|Nadia und Zauberstein|seriento
|
||||||
|
serienListe += line + "|" + page.url + "\n";
|
||||||
|
}
|
||||||
|
if(serienListe.length() > 0)
|
||||||
|
serienListe.pop_back();
|
||||||
|
|
||||||
|
//Entferne Html Sonderzeichen
|
||||||
|
serienListe = replace(serienListe, "&quot;", "\""); //
|
||||||
|
|
||||||
|
serienListe = replace(serienListe, "&", "&"); //
|
||||||
|
serienListe = replace(serienListe, "<", "<"); //
|
||||||
|
serienListe = replace(serienListe, ">", ">"); //
|
||||||
|
|
||||||
|
serienListe = replace(serienListe, "<br />", " "); //
|
||||||
|
serienListe = replace(serienListe, """, "\""); //
|
||||||
|
serienListe = replace(serienListe, "'", "'"); //
|
||||||
|
|
||||||
|
list += serienListe;
|
||||||
|
|
||||||
serienListe += line + "\n";
|
|
||||||
}
|
}
|
||||||
if(serienListe.length() > 0)
|
|
||||||
serienListe.pop_back();
|
|
||||||
|
|
||||||
//Entferne Html Sonderzeichen
|
|
||||||
serienListe = replace(serienListe, "&quot;", "\""); //
|
|
||||||
|
|
||||||
serienListe = replace(serienListe, "&", "&"); //
|
|
||||||
serienListe = replace(serienListe, "<", "<"); //
|
|
||||||
serienListe = replace(serienListe, ">", ">"); //
|
|
||||||
|
|
||||||
serienListe = replace(serienListe, "<br />", " "); //
|
|
||||||
serienListe = replace(serienListe, """, "\""); //
|
|
||||||
serienListe = replace(serienListe, "'", "'"); //
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//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 );
|
||||||
std::string alteListe;
|
std::string alteListe;
|
||||||
if(myFileBef.is_open()) {
|
if(myFileBef.is_open()) {
|
||||||
for(countBef = 0; std::getline(myFileBef,line); ++countBef) {
|
for(countBef = 0; std::getline(myFileBef, line); ++countBef) {
|
||||||
//Speicher alteListe für verglkeich nach Update
|
//Speicher alteListe für verglkeich nach Update
|
||||||
alteListe.append(line + "\n");
|
alteListe.append(line + "\n");
|
||||||
|
|
||||||
//Vergeliche neue und alte list => entfernte Serien
|
//Vergeliche neue und alte list => entfernte Serien
|
||||||
if(line != "" && serienListe.find(line) == std::string::npos) {
|
if(line != "" && list.find(line) == std::string::npos) {
|
||||||
std::cout << ((settings->colorless) ? "" : "\033[91m") << "Entfernt: '" << line.substr(line.find_last_of("|") + 1) << "'" << ((settings->colorless) ? "" : "\033[0m")
|
std::string tmp = std::string(line).erase(line.find_last_of('|'));
|
||||||
|
std::cout << ((settings->colorless) ? "" : "\033[91m") << "Entfernt: '" << tmp.substr(tmp.find_last_of("|") + 1) << "'" << ((settings->colorless) ? "" : "\033[0m")
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1444,24 +1481,25 @@ int ProgramManager::searchModus_update(Settings *settings)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//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 {
|
} else {
|
||||||
//Schreibe Liste in das TextFile
|
//Schreibe Liste in das TextFile
|
||||||
ofs << serienListe << std::endl;
|
ofs << list << 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
|
//Vergeliche neu mit Alt => gib neue Serien aus
|
||||||
if(line != "" && alteListe.find(line) == std::string::npos) {
|
if(line != "" && alteListe.find(line) == std::string::npos) {
|
||||||
std::cout << ((settings->colorless) ? "" : "\033[92m") << "Neu: '" << line.substr(line.find_last_of("|") + 1) << "'" << ((settings->colorless) ? "" : "\033[0m")
|
std::string tmp = std::string(line).erase(line.find_last_of('|'));
|
||||||
|
std::cout << ((settings->colorless) ? "" : "\033[92m") << "Neu: '" << tmp.substr(tmp.find_last_of("|") + 1) << "'" << ((settings->colorless) ? "" : "\033[0m")
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1473,7 +1511,11 @@ int ProgramManager::searchModus_update(Settings *settings)
|
|||||||
|
|
||||||
std::cout << ((settings->colorless) ? "" : "\033[93m") << "Serienunterschied: " << ( ((countAf - countBef) > 0) ? "+" : "") << countAf - countBef << " Serien." << "\033[0m" << std::endl;
|
std::cout << ((settings->colorless) ? "" : "\033[93m") << "Serienunterschied: " << ( ((countAf - countBef) > 0) ? "+" : "") << countAf - countBef << " Serien." << "\033[0m" << std::endl;
|
||||||
|
|
||||||
//Speicher Dateim des Updates...
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//Speicher Datum des Updates...
|
||||||
ofs.open(settings->lastUpdateDateFilePath, std::ios::trunc);
|
ofs.open(settings->lastUpdateDateFilePath, std::ios::trunc);
|
||||||
if(!ofs.is_open()) {
|
if(!ofs.is_open()) {
|
||||||
perror("Konnte UpdateDate-Datei nicht öffnen");
|
perror("Konnte UpdateDate-Datei nicht öffnen");
|
||||||
@ -1484,7 +1526,6 @@ int ProgramManager::searchModus_update(Settings *settings)
|
|||||||
ofs.close();
|
ofs.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user