make default modus stabil

This commit is contained in:
Your Name 2021-03-01 10:42:50 +01:00
parent 37afa24186
commit 0162441d26
8 changed files with 191 additions and 128 deletions

View File

@ -1,13 +1,14 @@
#include "accountManager.h" #include "accountManager.h"


AccountManager::AccountManager(std::string pathToFile, std::string pathToAccountNumberFile) AccountManager::AccountManager(std::string pathToFil, std::string pathToAccountNumberFile, PAGE page)
: pathToAccountNumberFile(pathToAccountNumberFile) : pathToAccountNumberFile(pathToAccountNumberFile + "_" + page.name_id), pageInUse(page)
{ {
std::ifstream ifs(pathToFile); std::string pathToAccountsFile = pathToFil + "_" + page.name_id;
std::ifstream ifs(pathToAccountsFile);
if(!ifs.is_open()) { if(!ifs.is_open()) {
if(writeDefault(pathToFile) != 0) if(writeDefault(pathToAccountsFile) != 0)
exit(12); exit(12);
ifs.open(pathToFile); ifs.open(pathToAccountsFile);
if(!ifs.is_open()) { if(!ifs.is_open()) {
std::cout << " => Error: Konnte Account File nicht öffnen" << std::endl; std::cout << " => Error: Konnte Account File nicht öffnen" << std::endl;
exit(13); exit(13);
@ -66,7 +67,8 @@ int AccountManager::writeDefault(std::string path)
std::cout << " => Erstelle Datei mit Accounts unter: " << path << "..." <<std::endl; std::cout << " => Erstelle Datei mit Accounts unter: " << path << "..." <<std::endl;
ofs << "# <- Am Anfang der Zeile deaktiviert diese." << std::endl; ofs << "# <- Am Anfang der Zeile deaktiviert diese." << std::endl;
ofs << "#Email/Passwort - Falls diese gleich sind, geht auch nur Email oder Passwort" << std::endl; ofs << "#Email/Passwort - Falls diese gleich sind, geht auch nur Email oder Passwort" << std::endl;
{
if( pageInUse.url == "serienstream.sx" || pageInUse.url == "s.to" ) {
ofs << "EntzueckendPackenderSkorpion@oida.icu" << std::endl; ofs << "EntzueckendPackenderSkorpion@oida.icu" << std::endl;
ofs << "HumorvollWundervollerDelfin@spam.care/HumorvollWundervollerDelfin@spam.care" << std::endl; ofs << "HumorvollWundervollerDelfin@spam.care/HumorvollWundervollerDelfin@spam.care" << std::endl;
ofs << "ExzellentPackenderHirsch@muell.icu/ExzellentPackenderHirsch@muell.icu" << std::endl; ofs << "ExzellentPackenderHirsch@muell.icu/ExzellentPackenderHirsch@muell.icu" << std::endl;
@ -157,7 +159,21 @@ int AccountManager::writeDefault(std::string path)
ofs << "GravierendIntensiverHase@oida.icu" << std::endl; ofs << "GravierendIntensiverHase@oida.icu" << std::endl;
ofs << "BerauschendUnglaublicherGorilla@oida.icu" << std::endl; ofs << "BerauschendUnglaublicherGorilla@oida.icu" << std::endl;
ofs << "GenuesslichPraechtigerDachs@spam.care" << std::endl; ofs << "GenuesslichPraechtigerDachs@spam.care" << std::endl;

} else if( pageInUse.url == "anicloud.io" ) {
ofs << "C322334ark1954@teleworm.us/C322334ark1954@teleworm.us" << std::endl;
ofs << "wemixex225@iconmle.com/wemixex225@iconmle.com" << std::endl;
ofs << "Thw86757utary@teleworm.us" << std::endl;
ofs << "thw811ssssutary@teleworm.us" << std::endl;
ofs << "Leonardoutary@teleworm.us" << std::endl;
ofs << "" << std::endl;
ofs << "" << std::endl;
ofs << "" << std::endl;

} else {
std::cout << " => WARNUNG: Keine standart Accounts für die Url '" << pageInUse.url << "' vorhanden." <<std::endl;
} }

ofs.close(); ofs.close();
return 0; return 0;
} }

View File

@ -5,6 +5,12 @@
#include <vector> #include <vector>
#include <fstream> #include <fstream>




#include "parameterManager.h"



struct Account { struct Account {
std::string Email, std::string Email,
Password; Password;
@ -14,13 +20,14 @@ struct Account {
class AccountManager class AccountManager
{ {
public: public:
AccountManager(std::string pathToFile, std::string pathToAccountNumberFile); AccountManager(std::string pathToFile, std::string pathToAccountNumberFile, PAGE page);
Account getNextAccount(); Account getNextAccount();
size_t getLastAccountNumber(); size_t getLastAccountNumber();


private: private:
std::vector<Account> accounts; std::vector<Account> accounts;
std::string pathToAccountNumberFile; std::string pathToAccountNumberFile;
PAGE pageInUse;
int setLastAccountNumber(size_t number); int setLastAccountNumber(size_t number);
int writeDefault(std::string path); int writeDefault(std::string path);



View File

@ -64,8 +64,8 @@ void PageManager::get_terminal_size(int& width) {
#if defined(_WIN32) #if defined(_WIN32)
CONSOLE_SCREEN_BUFFER_INFO csbi; CONSOLE_SCREEN_BUFFER_INFO csbi;
if( GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi) == 0 ) { if( GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi) == 0 ) {
if ( debugMode ) //if ( debugMode )
std::cout << " => WARNING: GetConsoleScreenBufferInfo failed => Use 9999 as max Msg-Length" << std::endl; //std::cout << " => WARNING: GetConsoleScreenBufferInfo failed => Use 9999 as max Msg-Length" << std::endl;
return; return;
} }


@ -300,13 +300,13 @@ checkNameRply PageManager::checkName(std::vector<PAGE> pages, std::string Name)
//für jede Seite //für jede Seite
for ( const auto &p : pages ) { for ( const auto &p : pages ) {


std::string html = getServerRequest("https://" + p.url +"/serie/stream/" + name).html; std::string html = getServerRequest("https://" + p.url + p.UrlDir + name).html;
if(html.find("Die gewünschte Serie wurde nicht gefunden oder ist im Moment deaktiviert.") != std::string::npos) { if(html.find("Die gewünschte Serie wurde nicht gefunden oder ist im Moment deaktiviert.") != std::string::npos) {
continue; continue;


} else if (html.find("404 - Seite nicht gefunden") != std::string::npos) { } else if (html.find("404 - Seite nicht gefunden") != std::string::npos) {
std::cout << "\33[2K\r => Ungültiger Name: '" << Name << "'" << std::endl; std::cout << "\33[2K\r => Ungültiger Name: '" << Name << "'" << std::endl;
return checkNameRply("", PAGE("", ""), checkNameRply::NEEDHELP); return checkNameRply("", PAGE("", ""), checkNameRply::NOTHING_FOUND);


} else if (html == "-1" || html == "") { } else if (html == "-1" || html == "") {
return checkNameRply("", PAGE("", ""), checkNameRply::FAILED); return checkNameRply("", PAGE("", ""), checkNameRply::FAILED);
@ -325,10 +325,10 @@ checkNameRply PageManager::checkName(std::vector<PAGE> pages, std::string Name)
return checkNameRply(name, Page, checkNameRply::SUCCESS);; return checkNameRply(name, Page, checkNameRply::SUCCESS);;
} else if ( count > 1) { } else if ( count > 1) {
std::cout << "\33[2K\r => Die Serie existiert auf mehreren Seiten " << pagesonExist << ": '" << name << "'" << std::endl; std::cout << "\33[2K\r => Die Serie existiert auf mehreren Seiten " << pagesonExist << ": '" << name << "'" << std::endl;
return checkNameRply("", PAGE("", ""), checkNameRply::NEEDHELP);; return checkNameRply("", PAGE("", ""), checkNameRply::NOTHING_FOUND);; //MULTIPLE OPTIONS FOUND!!!!
} else { } else {
std::cout << "\33[2K\r => Die gewünschte Serie wurde nicht gefunden oder ist im Moment deaktiviert: '" << Name << "'" << std::endl; std::cout << "\33[2K\r => Die gewünschte Serie wurde nicht gefunden oder ist im Moment deaktiviert: '" << Name << "'" << std::endl;
return checkNameRply("", PAGE("", ""), checkNameRply::NEEDHELP);; return checkNameRply("", PAGE("", ""), checkNameRply::NOTHING_FOUND);;
} }


} }

View File

@ -1,10 +1,15 @@
#ifndef MANAGEPAGE_H #ifndef MANAGEPAGE_H
#define MANAGEPAGE_H #define MANAGEPAGE_H



#include "accountManager.h" #include "accountManager.h"
#include "curl/curl.h" #include "curl/curl.h"
#include "parameterManager.h" // for isNumber #include "parameterManager.h" // for isNumber


#ifdef _WIN32
#include <windows.h>
#endif

#include <sstream> #include <sstream>
#include <unistd.h> // sleep #include <unistd.h> // sleep
#include <algorithm> #include <algorithm>
@ -22,7 +27,7 @@ struct Reply {
struct checkNameRply { struct checkNameRply {
std::string name; std::string name;
PAGE pageInUse; PAGE pageInUse;
enum STATUS { SUCCESS, FAILED, NEEDHELP } status; enum STATUS { SUCCESS, FAILED, NOTHING_FOUND, MULTIPLE_OPTIONS_FOUND } status;


checkNameRply(const std::string &name, const PAGE &p, const checkNameRply::STATUS &s ) checkNameRply(const std::string &name, const PAGE &p, const checkNameRply::STATUS &s )
: name(name), pageInUse(p), status(s) {} : name(name), pageInUse(p), status(s) {}

View File

@ -1007,6 +1007,7 @@ void unterOption_clean(Settings * settings, int argc, char **argv)
return; return;
} }


//Um altes zeug zu löschen
unsigned count = 0; unsigned count = 0;
if(fileExists(settings->cookieFilePath)) { if(fileExists(settings->cookieFilePath)) {
if(remove(settings->cookieFilePath.c_str()) != 0) { if(remove(settings->cookieFilePath.c_str()) != 0) {
@ -1024,6 +1025,27 @@ void unterOption_clean(Settings * settings, int argc, char **argv)
++count; ++count;
} }
} }
//UM sachen nach multipage update zu löschen
for ( const auto &p : settings->pages ) {
if(fileExists(settings->cookieFilePath + "_" + p.name_id)) {
if(remove((settings->cookieFilePath + "_" + p.name_id).c_str()) != 0) {
perror(( " => Error: Das löschen von " + settings->cookieFilePath + "_" + p.name_id + " ist fehlgeschlagen: ").c_str());
return;
} else
++count;
}

for (unsigned i = 0; i < UINT_MAX && fileExists(settings->cookieFilePath + "_" + p.name_id + std::to_string(i)); ++i) {
if(remove( (settings->cookieFilePath + "_" + p.name_id + std::to_string(i)).c_str() ) != 0) {
perror((" => Error: Das löschen von " + settings->cookieFilePath + "_" + p.name_id + std::to_string(i) + " ist fehlgeschlagen: ").c_str());
return;
} else {
++count;
}
}
}




if(count == 0) if(count == 0)
std::cout << " => Nichts zu tun: Keine Cookies vorhanden." << std::endl; std::cout << " => Nichts zu tun: Keine Cookies vorhanden." << std::endl;

View File

@ -7,6 +7,7 @@
#endif #endif
#endif #endif



#include <iostream> #include <iostream>
#include <getopt.h> #include <getopt.h>
#include <string.h> // strlen #include <string.h> // strlen
@ -19,11 +20,9 @@
#include <unistd.h> // readlink() #include <unistd.h> // readlink()
#include <dirent.h> #include <dirent.h>


#include "logger.h"


#ifdef _WIN32
#include <windows.h> #include "logger.h"
#endif


#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="
@ -56,12 +55,6 @@ struct PAGE {
url; url;
std::string urlAlphabetSerienList, std::string urlAlphabetSerienList,
UrlDir; UrlDir;


std::string accountFileName = "",
accountNumberFileName= "",
cookieFileName = "",
serienListName = "";
}; };


struct Settings { struct Settings {
@ -115,6 +108,10 @@ struct Settings {
#endif #endif


std::vector<PAGE> pages; std::vector<PAGE> pages;
enum MULTIPAGEFOUND_HANDLE { STOP, USE_PAGE_PRIORITY_HIGHEST, MANUEL_HANDLE } mpfH = MANUEL_HANDLE;
std::string pagePriority;


std::string name, std::string name,
accountFilePath = "", accountFilePath = "",
accountNumberPath= "", accountNumberPath= "",
@ -131,7 +128,7 @@ struct Settings {
languages = "GerDub,GerSub,Eng,", languages = "GerDub,GerSub,Eng,",
genaueHoster = "", genaueHoster = "",
version = VERSION, version = VERSION,
defaultFileVersion="1.8", defaultFileVersion="2.0",
default_checkPath = "", default_checkPath = "",
default_Searchmuster = "S%Staffel%E%Folge%"; default_Searchmuster = "S%Staffel%E%Folge%";



View File

@ -311,8 +311,6 @@ int ProgramManager::sucheNach_1_Serien(Settings *settings, PageManager &pageMana
} }


} }
std::cout << "NAME: " << finds << std::endl;



//suche Seite aus sucheregbnis in settings... //suche Seite aus sucheregbnis in settings...
bool found = false; bool found = false;
@ -338,7 +336,7 @@ int ProgramManager::sucheNach_1_Serien(Settings *settings, PageManager &pageMana
auto ret = pageManager.checkName( pages /*settings->pages dann glaub ich immer fehler, wenn serie auf 2 seiten excistiert*/, finds); auto ret = pageManager.checkName( pages /*settings->pages dann glaub ich immer fehler, wenn serie auf 2 seiten excistiert*/, finds);
if(ret.status == ret.FAILED) if(ret.status == ret.FAILED)
return 23; return 23;
else if( ret.status == ret.NEEDHELP ) { else if( ret.status == ret.NOTHING_FOUND ) {
std::cout << " => Error: Konnte die von der Suche vorgeschlagene Serie nicht finden." << std::endl; std::cout << " => Error: Konnte die von der Suche vorgeschlagene Serie nicht finden." << std::endl;
if(settings->debugMode) if(settings->debugMode)
std::cerr << ">>> Debug In " << __FUNCTION__ << ": Extracted Name from searchModus is invalid." << std::endl; std::cerr << ">>> Debug In " << __FUNCTION__ << ": Extracted Name from searchModus is invalid." << std::endl;
@ -394,7 +392,6 @@ int ProgramManager::checkLastUpdate(Settings *settings, ssize_t *days = nullptr)


int ProgramManager::defaultModus(Settings *settings) int ProgramManager::defaultModus(Settings *settings)
{ {
AccountManager accountManager(settings->accountFilePath, settings->accountNumberPath);


//Wenn kein Name mit -n Angegeben wurde: //Wenn kein Name mit -n Angegeben wurde:
if(settings->name == "") { if(settings->name == "") {
@ -447,7 +444,7 @@ int ProgramManager::defaultModus(Settings *settings)


if(retVal.status == retVal.FAILED) if(retVal.status == retVal.FAILED)
return 67; return 67;
else if(retVal.status == retVal.NEEDHELP) { else if(retVal.status == retVal.NOTHING_FOUND) {
//Wenn nicht, dann fühe noch eine Suche nach ähnlichen durch && Wenn nur 1ne dacnn frag ob es diese ist. //Wenn nicht, dann fühe noch eine Suche nach ähnlichen durch && Wenn nur 1ne dacnn frag ob es diese ist.
int res = 0; int res = 0;
if( ( res = sucheNach_1_Serien(settings, pageManager, retVal) ) != 0) { if( ( res = sucheNach_1_Serien(settings, pageManager, retVal) ) != 0) {
@ -455,10 +452,28 @@ int ProgramManager::defaultModus(Settings *settings)
std::cerr << ">>> Debug In " << __FUNCTION__ << ": sucheNach_1_Serien failed or found more options." << std::endl; std::cerr << ">>> Debug In " << __FUNCTION__ << ": sucheNach_1_Serien failed or found more options." << std::endl;
return (res == -10101) ? 0 : 202; return (res == -10101) ? 0 : 202;
} }
} else if (retVal.status == retVal.MULTIPLE_OPTIONS_FOUND) {
switch (settings->mpfH) {
case Settings::STOP:
break;
case Settings::MANUEL_HANDLE: {
int res = 0;
if( ( res = sucheNach_1_Serien(settings, pageManager, retVal) ) != 0) {
if(settings->debugMode)
std::cerr << ">>> Debug In " << __FUNCTION__ << ": sucheNach_1_Serien failed or found more options." << std::endl;
return (res == -10101) ? 0 : 202;
} }
break;
} case Settings::USE_PAGE_PRIORITY_HIGHEST:
break;

}
}

std::string nameInUrl = retVal.name; std::string nameInUrl = retVal.name;
PAGE page = retVal.pageInUse; PAGE page = retVal.pageInUse;

AccountManager accountManager(settings->accountFilePath + "_" + page.name_id, settings->accountNumberPath + "_" + page.name_id, page);
pageManager.setCookieFilePath(settings->cookieFilePath + "_" + page.name_id);




/* Wenn multihtreading seaktiviert ist, normal login sonst bereite threads vor /* Wenn multihtreading seaktiviert ist, normal login sonst bereite threads vor
@ -470,16 +485,16 @@ int ProgramManager::defaultModus(Settings *settings)


if(settings->maxThreads > 0) { if(settings->maxThreads > 0) {
for (unsigned i = 0; i < settings->maxThreads; ++i) { for (unsigned i = 0; i < settings->maxThreads; ++i) {
if(dirExists(settings->cookieFilePath + std::to_string( i ))) { if(dirExists(settings->cookieFilePath + "_" + page.name_id + std::to_string( i ))) {
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: Es existiert bereits ein Ordner mit diesem Namen: \n '"
<< settings->cookieFilePath + std::to_string( i ) << "'." << std::endl; << settings->cookieFilePath + "_" + page.name_id + std::to_string( i ) << "'." << std::endl;
return 174; return 174;
} }
PageManager * pm = new PageManager(settings->proxy_ip + ":" + std::to_string(settings->proxy_port), settings->cookieFilePath + std::to_string( i )); PageManager * pm = new PageManager(settings->proxy_ip + ":" + std::to_string(settings->proxy_port), settings->cookieFilePath + "_" + page.name_id + std::to_string( i ));
pm->setDebugMode(settings->debugMode); pm->setDebugMode(settings->debugMode);


//pm->setProxy(settings->proxy_ip, settings->proxy_port); //pm->setProxy(settings->proxy_ip, settings->proxy_port);
//pm->setCookieFilePath(settings->cookieFilePath + std::to_string( i )); //pm->setCookieFile Path(settings->cookieFile Path + std::to_string( i ));


ThreadData * newThreadData = new ThreadData(i, 0, nameInUrl, -1, settings, &accountManager, pm, page); ThreadData * newThreadData = new ThreadData(i, 0, nameInUrl, -1, settings, &accountManager, pm, page);
threadList.push_back(newThreadData); threadList.push_back(newThreadData);
@ -669,7 +684,7 @@ int ProgramManager::defaultModus(Settings *settings)


int ProgramManager::directLinkModus(Settings *settings) int ProgramManager::directLinkModus(Settings *settings)
{ {
AccountManager accountManager(settings->accountFilePath, settings->accountNumberPath); AccountManager accountManager(settings->accountFilePath, settings->accountNumberPath, PAGE("", ""));


if(settings->name == "") { if(settings->name == "") {
std::cout << " => Kein(e) Link(s) angegeben." << std::endl; std::cout << " => Kein(e) Link(s) angegeben." << std::endl;
@ -854,13 +869,13 @@ int ProgramManager::infoModus(Settings *settings)
auto retV = pageManager.checkName(settings->pages, settings->name); auto retV = pageManager.checkName(settings->pages, settings->name);
if(retV.status == retV.FAILED) if(retV.status == retV.FAILED)
return 145; return 145;
else if(retV.status == retV.NEEDHELP) { else if(retV.status == retV.NOTHING_FOUND) {
//Wenn nicht, dann fühe noch eine Suche nach ähnlichen durch. //Wenn nicht, dann fühe noch eine Suche nach ähnlichen durch.
int res = 0; int res = 0;
if( ( res = sucheNach_1_Serien(settings, pageManager, retV) ) != 0) { if( ( res = sucheNach_1_Serien(settings, pageManager, retV) ) != 0) {
if(settings->debugMode) if(settings->debugMode)
std::cerr << ">>> Debug In " << __FUNCTION__ << ": sucheNach_1_Serien function failed." << std::endl; std::cerr << ">>> Debug In " << __FUNCTION__ << ": sucheNach_1_Serien function failed." << std::endl;
return (res = -10101) ? 0 : 28; return (res == -10101) ? 0 : 28;
} }
} }
std::string nameInUrl = retV.name; std::string nameInUrl = retV.name;

View File

@ -1,6 +1,7 @@
#ifndef MANAGEPROGRAM_H #ifndef MANAGEPROGRAM_H
#define MANAGEPROGRAM_H #define MANAGEPROGRAM_H



#include "pageManager.h" #include "pageManager.h"
#include "parameterManager.h" #include "parameterManager.h"
#include "accountManager.h" #include "accountManager.h"