forked from markus/S_New4
removed test_dir
This commit is contained in:
parent
cf70da9f59
commit
64f362c6f7
@ -1,210 +0,0 @@
|
||||
#include "accountManager.h"
|
||||
|
||||
AccountManager::AccountManager(std::string pathToFile, std::string pathToAccountNumberFile)
|
||||
: pathToAccountNumberFile(pathToAccountNumberFile)
|
||||
{
|
||||
std::ifstream ifs(pathToFile);
|
||||
if(!ifs.is_open()) {
|
||||
if(writeDefault(pathToFile) != 0)
|
||||
exit(12);
|
||||
ifs.open(pathToFile);
|
||||
if(!ifs.is_open()) {
|
||||
std::cout << " => Error: Konnte Account File nicht öffnen" << std::endl;
|
||||
exit(13);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::string line;
|
||||
while (std::getline(ifs, line)) {
|
||||
if(line.length() > 0 && line[0] == '#')
|
||||
continue;
|
||||
Account account;
|
||||
size_t Delimeter = line.find("/");
|
||||
|
||||
if(Delimeter == std::string::npos) {
|
||||
account.Email = line;
|
||||
account.Password = line;
|
||||
} else {
|
||||
account.Email = std::string(line).erase(Delimeter, line.length() - Delimeter);
|
||||
account.Password = line.erase(0, Delimeter + 1);
|
||||
}
|
||||
if(account.Email == "" || account.Password == "")
|
||||
continue;
|
||||
else
|
||||
accounts.push_back(account);
|
||||
}
|
||||
|
||||
ifs.close();
|
||||
|
||||
}
|
||||
|
||||
Account AccountManager::getNextAccount()
|
||||
{
|
||||
if(accounts.size() == 0) {
|
||||
std::cout << " => Error: Keine Accounts vorhanden." << std::endl;
|
||||
exit(36);
|
||||
}
|
||||
size_t accountNumber = getLastAccountNumber();
|
||||
accountNumber++;
|
||||
|
||||
if( accountNumber >= accounts.size() )
|
||||
accountNumber=0;
|
||||
if(setLastAccountNumber(accountNumber) != 0)
|
||||
exit(45);
|
||||
|
||||
return accounts.at(accountNumber);
|
||||
}
|
||||
|
||||
int AccountManager::writeDefault(std::string path)
|
||||
{
|
||||
std::ofstream ofs(path);
|
||||
if(!ofs.is_open()) {
|
||||
perror((std::string(" => Error: Konnte Account Datei nicht öffnen: ") + path).c_str());
|
||||
return -1;
|
||||
}
|
||||
std::cout << " => Erstelle Datei mit Accounts unter: " << path << "..." <<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 << "EntzueckendPackenderSkorpion@oida.icu" << std::endl;
|
||||
ofs << "HumorvollWundervollerDelfin@spam.care/HumorvollWundervollerDelfin@spam.care" << std::endl;
|
||||
ofs << "ExzellentPackenderHirsch@muell.icu/ExzellentPackenderHirsch@muell.icu" << std::endl;
|
||||
ofs << "GrandiosLeuchtenderPanda@papierkorb.me" << std::endl;
|
||||
ofs << "AttraktivPositiverSteinbock@magspam.net" << std::endl;
|
||||
ofs << "FreundlichKostbarerSteinbock@spam.care" << std::endl;
|
||||
ofs << "FabelhaftSelbstsichererUhu@spam.care" << std::endl;
|
||||
ofs << "HumorvollSinnlicherRabe@muell.icu" << std::endl;
|
||||
ofs << "AnspruchsvollTraumhafterPavian@ultra.fyi" << std::endl;
|
||||
ofs << "FaszinierendRiskanterLuchs@magspam.net" << std::endl;
|
||||
ofs << "BeruehmtMystischerPanda@ultra.fyi" << std::endl;
|
||||
ofs << "CharmantRasanterLoewe@existiert.net" << std::endl;
|
||||
ofs << "BedeutendLuesternerAal@existiert.net" << std::endl;
|
||||
ofs << "ElegantSelbstsichererAdler@ultra.fyi" << std::endl;
|
||||
ofs << "FaszinierendKoeniglicherBaer@spam.care" << std::endl;
|
||||
ofs << "CharmantKostbarerLoewe@magspam.net" << std::endl;
|
||||
ofs << "BedeutendPrallerSkorpion@muellemail.com" << std::endl;
|
||||
ofs << "FreundlichPerfekterRochen@muellmail.com" << std::endl;
|
||||
ofs << "AusgelassenKostbarerBasilisk@magspam.net" << std::endl;
|
||||
ofs << "FabelhaftLebhafterSchakal@ultra.fyi" << std::endl;
|
||||
ofs << "ExzellentSchoenerSteinbock@existiert.net" << std::endl;
|
||||
ofs << "ErhellendLustvollerAdler@muell.icu" << std::endl;
|
||||
ofs << "ExzellentIdealerSchakal@muell.icu" << std::endl;
|
||||
ofs << "BrillantVitalerSalamander@spam.care" << std::endl;
|
||||
ofs << "BezauberndRiesigerSchakal@oida.icu" << std::endl;
|
||||
ofs << "DynamischWarmerBaer@magspam.net" << std::endl;
|
||||
ofs << "EmotionalLeidenschaftlicherBaer@oida.icu" << std::endl;
|
||||
ofs << "BewundernswertWarmerSchwan@oida.icu" << std::endl;
|
||||
ofs << "HuebschUnfassbarerAal@papierkorb.me" << std::endl;
|
||||
ofs << "FroehlichWundervollerBiber@muellmail.com" << std::endl;
|
||||
ofs << "BefreiendWilderDelfin@spam.care" << std::endl;
|
||||
ofs << "FreundlichStilvollerTiger@oida.icu" << std::endl;
|
||||
ofs << "EchtKoeniglicherStorch@existiert.net" << std::endl;
|
||||
ofs << "BefluegeltPrallerSchwan@spam.care" << std::endl;
|
||||
ofs << "ErhellendSeltenerSeeloewe@ultra.fyi" << std::endl;
|
||||
ofs << "FreundlichZuverlaessigerSchwan@spam.care" << std::endl;
|
||||
ofs << "HervorragendWundervollerReiher@oida.icu" << std::endl;
|
||||
ofs << "AnspruchsvollStilvollerUhu@magspam.net" << std::endl;
|
||||
ofs << "AnmutigTraumhafterHai@muellemail.com" << std::endl;
|
||||
ofs << "AtemberaubendIdealerTapir@ultra.fyi" << std::endl;
|
||||
ofs << "GeheimLeuchtenderLuchs@muellemail.com" << std::endl;
|
||||
ofs << "DuftendKlarerTapir@muellmail.com" << std::endl;
|
||||
ofs << "GeheimUnwiderstehlicherRabe@muell.icu" << std::endl;
|
||||
ofs << "ExtravagantSpektakulaererAdler@spam.care" << std::endl;
|
||||
ofs << "BildlichWarmerLoewe@oida.icu" << std::endl;
|
||||
ofs << "AktivKlarerHai@spam.care" << std::endl;
|
||||
ofs << "AktivKostbarerElch@oida.icu" << std::endl;
|
||||
ofs << "Strust1991@jourrapide.com" << std::endl;
|
||||
ofs << "Natchoughe1928@dayrep.com" << std::endl;
|
||||
ofs << "zweirot@einrot.com" << std::endl;
|
||||
ofs << "AktivMagischerFrosch@existiert.net" << std::endl;
|
||||
ofs << "ErhellendPerfekterDachs@existiert.net" << std::endl;
|
||||
ofs << "ojfvwj.fgf@existiert.net" << std::endl;
|
||||
ofs << "lusiouae@wegwerfemail.de" << std::endl;
|
||||
ofs << "fraiwrou@wegwerfemail.de" << std::endl;
|
||||
ofs << "driotean@wegwerfemail.de" << std::endl;
|
||||
ofs << "tiaprour@wegwerfemail.de" << std::endl;
|
||||
ofs << "FeurigWarmerPapagei@existiert.net" << std::endl;
|
||||
ofs << "FrischStilvollerPavian@magspam.net" << std::endl;
|
||||
ofs << "FeurigZaghafterLoewe@muellmail.com" << std::endl;
|
||||
ofs << "GigantischKoeniglicherSchwan@magspam.net" << std::endl;
|
||||
ofs << "FreizuegigPersoenlicherLemming@spam.care" << std::endl;
|
||||
ofs << "BelebtIntelligenterHusky@papierkorb.me" << std::endl;
|
||||
ofs << "FreundlichMaximalerSpecht@muellmail.com" << std::endl;
|
||||
ofs << "FreundlichStarkerHirsch@ultra.fyi" << std::endl;
|
||||
ofs << "ErstklassigRasanterElch@oida.icu" << std::endl;
|
||||
ofs << "FreundlichStarkerPavian@ultra.fyi" << std::endl;
|
||||
ofs << "EinfuehlsamRiskanterPapagei@oida.icu" << std::endl;
|
||||
ofs << "FantastischPositiverHirsch@existiert.net" << std::endl;
|
||||
ofs << "GeborgenIndividuellerOtter@muell.icu" << std::endl;
|
||||
ofs << "HervorragendSensibelerWal@oida.icu" << std::endl;
|
||||
ofs << "HerrlichIndividuellerPelikan@spam.care" << std::endl;
|
||||
ofs << "HerrlichLeuchtenderTapir@muellmail.com" << std::endl;
|
||||
ofs << "ErstaunlichIntensiverEsel@magspam.net" << std::endl;
|
||||
ofs << "ExtravagantPraechtigerWal@muellemail.com" << std::endl;
|
||||
ofs << "GravierendWundervollerFalke@spam.care" << std::endl;
|
||||
ofs << "EntzueckendLebhafterFlamingo@magspam.net" << std::endl;
|
||||
ofs << "GeheimSprachloserStorch@existiert.net" << std::endl;
|
||||
ofs << "GravierendVitalerOtter@spam.care" << std::endl;
|
||||
ofs << "GrenzenlosInteressanterElch@oida.icu" << std::endl;
|
||||
ofs << "HellPackenderGoldfisch@muellemail.com" << std::endl;
|
||||
ofs << "AbenteuerlichSelbstloserFalke@muell.icu" << std::endl;
|
||||
ofs << "EmotionalZaghafterPapagei@magspam.net" << std::endl;
|
||||
ofs << "HellLiebenswerterElefant@muellemail.com" << std::endl;
|
||||
ofs << "BildlichImponierenderEsel@muellemail.com" << std::endl;
|
||||
ofs << "ErstaunlichSprachloserPapagei@ultra.fyi" << std::endl;
|
||||
ofs << "BerauschendLebendigerDelfin@ultra.fyi" << std::endl;
|
||||
ofs << "GravierendIntensiverHase@oida.icu" << std::endl;
|
||||
ofs << "BerauschendUnglaublicherGorilla@oida.icu" << std::endl;
|
||||
ofs << "GenuesslichPraechtigerDachs@spam.care" << std::endl;
|
||||
}
|
||||
ofs.close();
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t AccountManager::getLastAccountNumber()
|
||||
{
|
||||
std::ifstream fStream;
|
||||
fStream.open(pathToAccountNumberFile);
|
||||
if(!fStream.is_open()) {
|
||||
std::ofstream ofs;
|
||||
ofs.open(pathToAccountNumberFile);
|
||||
ofs << "0" << std::endl;
|
||||
ofs.close();
|
||||
fStream.open(pathToAccountNumberFile);
|
||||
if(!fStream.is_open()) {
|
||||
perror(" => Error: Konnte Account Number Datei nicht erstellen");
|
||||
exit(34);
|
||||
}
|
||||
}
|
||||
|
||||
std::string content( (std::istreambuf_iterator<char>(fStream) ), (std::istreambuf_iterator<char>() ) );
|
||||
return static_cast<size_t>( atoi(content.c_str()) );
|
||||
}
|
||||
|
||||
int AccountManager::setLastAccountNumber(size_t number)
|
||||
{
|
||||
std::ofstream ofs;
|
||||
ofs.open(pathToAccountNumberFile, std::ios::trunc);
|
||||
if(!ofs.is_open()) {
|
||||
std::cout << " => Error: Account Number Datei ist nicht geöffnet." << std::endl;
|
||||
return 110;
|
||||
}
|
||||
//fStream.clear();
|
||||
ofs << number << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool AccountManager::isDirExist(const std::string& path)
|
||||
{
|
||||
struct stat info;
|
||||
if (stat(path.c_str(), &info) != 0) {
|
||||
return false;
|
||||
}
|
||||
return (info.st_mode & S_IFDIR) != 0;
|
||||
}
|
||||
|
||||
bool AccountManager::createDir(std::string path, std::string atLinux)
|
||||
{
|
||||
return system(std::string("mkdir " + atLinux + "'" + path +"'").c_str()); // -p if is linux
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
#ifndef ACCOUNTMANAGER_H
|
||||
#define ACCOUNTMANAGER_H
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <sys/stat.h>
|
||||
#include <fstream>
|
||||
|
||||
struct Account {
|
||||
std::string Email, Password;
|
||||
};
|
||||
|
||||
|
||||
class AccountManager
|
||||
{
|
||||
public:
|
||||
AccountManager(std::string pathToFile, std::string pathToAccountNumberFile);
|
||||
Account getNextAccount();
|
||||
|
||||
int writeDefault(std::string path);
|
||||
size_t getLastAccountNumber();
|
||||
int setLastAccountNumber(size_t number);
|
||||
|
||||
bool isDirExist(const std::string& path);
|
||||
bool createDir(std::string path, std::string atLinux = "-p ");
|
||||
|
||||
private:
|
||||
std::vector<Account> accounts;
|
||||
std::string pathToAccountNumberFile;
|
||||
};
|
||||
|
||||
#endif // ACCOUNTMANAGER_H
|
14
g++/main.cpp
14
g++/main.cpp
@ -1,14 +0,0 @@
|
||||
#include "programManager.h"
|
||||
#include "parameterManager.h"
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
ProgramManager mainProgram;
|
||||
Settings settings;
|
||||
int res = manageParameter(settings, argc, argv);
|
||||
if(res != 0)
|
||||
return (res == -1) ? 0 : res;
|
||||
|
||||
return mainProgram.start(&settings);
|
||||
}
|
@ -1,347 +0,0 @@
|
||||
#include "pageManager.h"
|
||||
|
||||
PageManager::PageManager(std::string sock5Proxy, std::string cookieFilePath)
|
||||
: sock5Proxy(sock5Proxy), cookieFilePath(cookieFilePath)
|
||||
{
|
||||
curl_global_init(CURL_GLOBAL_ALL);
|
||||
}
|
||||
|
||||
PageManager::~PageManager()
|
||||
{
|
||||
curl_global_cleanup();
|
||||
}
|
||||
|
||||
void PageManager::setProxy(std::string ip, int port)
|
||||
{
|
||||
this->sock5Proxy = "socks5://" + ip + ":" + std::to_string(port);
|
||||
}
|
||||
|
||||
void PageManager::setCookieFilePath(std::string path)
|
||||
{
|
||||
this->cookieFilePath = path;
|
||||
}
|
||||
|
||||
void PageManager::setDebugMode(bool status)
|
||||
{
|
||||
this->debugMode = status;
|
||||
}
|
||||
|
||||
size_t WriteCallback(void *contents, size_t size, size_t nmemb, void *userp)
|
||||
{
|
||||
//Function für CURL
|
||||
static_cast<std::string*>(userp)->append(static_cast<char*>(contents),size * nmemb);
|
||||
return size * nmemb;
|
||||
}
|
||||
|
||||
Reply PageManager::getServerRequest(std::string Url, bool useCookies, std::string data, bool generateCookieFile)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res;
|
||||
std::string readBuffer;
|
||||
char *url;
|
||||
std::string returnUrl;
|
||||
|
||||
std::cout << ( "\33[2K\rLade: '" + Url + "'..." ) << std::flush;
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(!curl) {
|
||||
perror("\33[2K\r => Error: Curl easy init failed");
|
||||
return Reply("-1");
|
||||
}
|
||||
|
||||
//Settings
|
||||
curl_easy_setopt(curl, CURLOPT_URL, Url.c_str()); //Url für Curl
|
||||
curl_easy_setopt(curl, CURLOPT_PROXY, sock5Proxy.c_str() ); //Sock5Proxy für Curl
|
||||
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); //follows redirection
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback); // Funktion zum Speichern des outputs in einem string
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer); //Legt die Variable readbuffer fest
|
||||
curl_easy_setopt(curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:64.0) Gecko/20100101 Firefox/64.0");
|
||||
if(useCookies)
|
||||
curl_easy_setopt(curl, CURLOPT_COOKIEFILE, cookieFilePath.c_str());
|
||||
if(data != "")
|
||||
curl_easy_setopt (curl, CURLOPT_POSTFIELDS, data.c_str());
|
||||
if(generateCookieFile)
|
||||
curl_easy_setopt (curl, CURLOPT_COOKIEJAR, cookieFilePath.c_str());
|
||||
|
||||
int maxTimeout = 10;
|
||||
for (int timeout = 1; timeout <= maxTimeout; ++timeout) {
|
||||
/* Perform the request, res will get the return code */
|
||||
res = curl_easy_perform(curl);
|
||||
std::cout << "\33[2K\r" << std::flush;
|
||||
|
||||
if(res != CURLE_OK) {
|
||||
if(timeout == maxTimeout) {
|
||||
perror((std::string("\33[2K\r => Error: curl_easy_perform() failed: ") + curl_easy_strerror(res)).c_str());
|
||||
return Reply("-1");
|
||||
} else {
|
||||
std::cout << std::string( "\33[2K\r => Warning: Versuch " + std::to_string(timeout) + " von " + std::to_string(maxTimeout) + ": curl_easy_perform() failed: " + curl_easy_strerror(res) )<< std::flush;
|
||||
sleep(1);
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Get Url
|
||||
res = curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_URL, &url);
|
||||
if( res != CURLE_OK || !url ) {
|
||||
perror((std::string("\33[2K\r => Error: curl_easy_getinfo failed: ") + curl_easy_strerror(res)).c_str());
|
||||
return Reply("-1");
|
||||
} else
|
||||
returnUrl=url;
|
||||
|
||||
|
||||
/* always cleanup */ /* Mach den Griff zu, schreib die Kekse! */
|
||||
curl_easy_cleanup(curl);
|
||||
|
||||
return Reply(readBuffer, returnUrl);
|
||||
}
|
||||
|
||||
int PageManager::login(Account account)
|
||||
{
|
||||
if(debugMode)
|
||||
std::cout << " > Melde mit neuem Account an: Email: " << account.Email << " Passowort: " << account.Password << std::endl;
|
||||
|
||||
std::string html = getServerRequest("https://s.to/login", false, std::string("email=" + account.Email + "&password=" + account.Password), true ).html;
|
||||
if(html == "" )
|
||||
return 0;
|
||||
else if (html.find("Das Feld Email muss eine gültige E-Mail-Adresse enthalten.") != std::string::npos)
|
||||
std::cout << " => Error: Login failed: Das Feld Email muss eine gültige E-Mail-Adresse enthalten." << std::endl
|
||||
<< " Email: '" << account.Email << "' Passwort: '" << account.Password << "'" << std::endl;
|
||||
else if (html.find("Das Passwort ist nicht korrekt") != std::string::npos)
|
||||
std::cout << " => Error: Login failed: Das Passwort ist nicht korrekt." << std::endl
|
||||
<< " Email: '" << account.Email << "' Passwort: '" << account.Password << "'" << std::endl;
|
||||
else if (html.find("Ein Account mit dieser E-Mail Adresse wurde nicht gefunden.") != std::string::npos)
|
||||
std::cout << " => Error: Login failed: Ein Account mit dieser E-Mail Adresse wurde nicht gefunden." << std::endl
|
||||
<< " Email: '" << account.Email << "' Passwort: '" << account.Password << "'" << std::endl;
|
||||
else if(html == "-1")
|
||||
return -1;
|
||||
else
|
||||
std::cout << " => Error: Login failed: Keine Weiterleitung bei Login." << std::endl
|
||||
<< " Email: '" << account.Email << "' Passwort: '" << account.Password << "'" << std::endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
std::string PageManager::getUrlAfterRedirect(std::string Url)
|
||||
{
|
||||
return getServerRequest(Url, true).url;
|
||||
}
|
||||
|
||||
std::string PageManager::checkName(std::string Name)
|
||||
{
|
||||
std::string name = replace(Name, " ", "-");
|
||||
|
||||
std::string html = getServerRequest("https://s.to/serie/stream/" + name).html;
|
||||
if(html.find("Die gewünschte Serie wurde nicht gefunden oder ist im Moment deaktiviert.") != std::string::npos) {
|
||||
std::cout << "\33[2K\r => Error: Die gewünschte Serie wurde nicht gefunden oder ist im Moment deaktiviert: " << Name << std::endl;
|
||||
return "-1";
|
||||
} else if (html.find("404 - Seite nicht gefunden") != std::string::npos) {
|
||||
std::cout << "\33[2K\r => Error: Ungültiger Name: " << Name << std::endl;
|
||||
return "-1";
|
||||
} else if (html == "-1") {
|
||||
return "-1";
|
||||
}
|
||||
else {
|
||||
std::cout << "\33[2K\r > Name: " << name << std::endl;
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
std::string PageManager::getLinks(std::string HTML)
|
||||
{
|
||||
size_t pos = HTML.find("<ul class=\"row\">");
|
||||
if(pos == std::string::npos) {
|
||||
std::cout << " => Error: Konnte Position von \"" << "<ul class=\"row\">" << " nicht finden" <<std::endl;
|
||||
return "";
|
||||
}
|
||||
|
||||
HTML.erase(0,pos);
|
||||
|
||||
pos = HTML.find("<script async=");
|
||||
if(pos == std::string::npos) {
|
||||
std::cout << " => Error: Konnte Position von \"" << "<script async=" << "\" nicht finden" <<std::endl;
|
||||
return "";
|
||||
}
|
||||
|
||||
HTML.erase(pos,HTML.length() - pos);
|
||||
HTML = replace(HTML, "\n", ""); //HTML.replace("\n","").replace("</span>", "\n");
|
||||
HTML = replace(HTML, "</span>", "\n");
|
||||
HTML = grep(HTML,"href=\"/redirect/");
|
||||
|
||||
std::istringstream iStrStream( HTML + "\n" );
|
||||
std::string line, ReturnValue;
|
||||
size_t pos2;
|
||||
|
||||
while (getline(iStrStream, line).good()) {
|
||||
if(line == "")
|
||||
break;
|
||||
pos=line.find("data-lang-key=");
|
||||
if(pos == std::string::npos) {
|
||||
std::cout << "Error: Konnte Position von \"data-lang-key=\" nicht finden." << std::endl;
|
||||
continue;
|
||||
}
|
||||
//entferne alles bis pos
|
||||
line.erase(0,pos);
|
||||
|
||||
pos=line.find("data-link-id=");
|
||||
if(pos == std::string::npos) {
|
||||
std::cout << "Error: Konnte Position von \"data-link-id=\" nicht finden." << std::endl;
|
||||
continue;
|
||||
}
|
||||
pos2=line.find("href=\"");
|
||||
if(pos2 == std::string::npos) {
|
||||
std::cout << "Error: Konnte Position von 'href=\"' nicht finden." << std::endl;
|
||||
continue;
|
||||
}
|
||||
//Entferne alles von pos bis pos2
|
||||
line.erase(pos,pos2-pos);
|
||||
|
||||
pos=line.find("target=");
|
||||
if(pos == std::string::npos) {
|
||||
std::cout << "Error: Konnte Position von \"target=\" nicht finden." << std::endl;
|
||||
continue;
|
||||
}
|
||||
pos2=line.find("title=");
|
||||
if(pos2 == std::string::npos) {
|
||||
std::cout << "Error: Konnte Position von \"title=\" nicht finden." << std::endl;
|
||||
continue;
|
||||
}
|
||||
//entferne alles von pos bis pos2
|
||||
line.erase(pos,pos2-pos);
|
||||
|
||||
pos=line.find("><");
|
||||
if(pos == std::string::npos) {
|
||||
std::cout << "Error: Konnte Position von \"><\" nicht finden." << std::endl;
|
||||
continue;
|
||||
}
|
||||
//entferne alles von pos bis zum ende
|
||||
line.erase(pos,line.length()-pos);
|
||||
|
||||
line = replace(line, "title=\"Hoster ", "hoster=\"");
|
||||
ReturnValue+=line+"\n";
|
||||
}
|
||||
|
||||
if(ReturnValue.length() > 0)
|
||||
return ReturnValue.erase( ReturnValue.size()-1 , 1);
|
||||
else
|
||||
return "";
|
||||
|
||||
}
|
||||
|
||||
std::string PageManager::replace(std::string str, std::string substr1, std::string substr2)
|
||||
{
|
||||
if(substr1 == "")
|
||||
return str;
|
||||
size_t index = 0;
|
||||
for (index = str.find(substr1, index); index != std::string::npos; index = str.find(substr1, index + strlen(substr1.c_str())) )
|
||||
str.replace(index, strlen(substr1.c_str()), substr2);
|
||||
return str;
|
||||
}
|
||||
|
||||
int PageManager::counterContains(std::string text, std::string substring_with_prozent_i_for_number, int starte_mit_dieser_Zahl)
|
||||
{
|
||||
int i = starte_mit_dieser_Zahl;
|
||||
for (; text.find( replace(substring_with_prozent_i_for_number, "%i", std::to_string(i)) ) != std::string::npos; i++);
|
||||
return i-1;
|
||||
}
|
||||
|
||||
std::string PageManager::grep(std::string text, std::string substring, bool IgnoreCaseSensetifity)
|
||||
{
|
||||
std::istringstream iStrStream(text + "\n");
|
||||
std::string line, returnValue;
|
||||
while( std::getline(iStrStream, line).good() ) //auto start_of_line_position = begin( line ); //auto end_of_line_position = end( line );
|
||||
if(line.find(substring) != std::string::npos || ( IgnoreCaseSensetifity && upper_string(line).find(upper_string(substring)) != std::string::npos) )
|
||||
returnValue += line + "\n";
|
||||
if(returnValue.length() >= 1)
|
||||
return returnValue.erase(returnValue.length()-1,1);
|
||||
else
|
||||
return "";
|
||||
|
||||
}
|
||||
|
||||
std::string PageManager::upper_string(const std::string &str)
|
||||
{
|
||||
std::string upper;
|
||||
transform(str.begin(), str.end(), std::back_inserter(upper), toupper);
|
||||
return upper;
|
||||
}
|
||||
|
||||
int PageManager::writeToFile(std::string path, std::string text)
|
||||
{
|
||||
if(path == "")
|
||||
return 0;
|
||||
std::ofstream of;
|
||||
of.open(path, std::ios::out | std::ios::app);
|
||||
if(!of.is_open()) {
|
||||
perror(" => Error: Konnte Output Datei nicht öffnen");
|
||||
return -1;
|
||||
}
|
||||
of << text << std::endl;
|
||||
of.close();
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::string PageManager::chooseHosterLink(std::string HosterList, std::string Hoster_with_Highst_Priority_at_First, std::string languages_with_highst_priority_at_first)
|
||||
{
|
||||
std::istringstream SListLang ( replace( languages_with_highst_priority_at_first, ",", "\n") + "\n" );
|
||||
std::istringstream SListHoster( replace( Hoster_with_Highst_Priority_at_First, ",", "\n") + "\n" );
|
||||
|
||||
int LangId = 0;
|
||||
size_t pos = 0;
|
||||
std::string LanguageSortedHoster, Line, langId, hoster;
|
||||
//QTextStream stream();
|
||||
|
||||
//Für jede Sprache:
|
||||
while (getline(SListLang, langId).good()) {
|
||||
|
||||
if ( langId == "GerDub" )
|
||||
LangId=1;
|
||||
else if ( langId == "Eng" )
|
||||
LangId=2;
|
||||
else if ( langId == "GerSub" )
|
||||
LangId=3;
|
||||
else {
|
||||
std::cout << " => Error: Unbekannte Sprache: " << langId << std::endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
//Liste aller Links mit der Sprache des durchgangs der schleife
|
||||
LanguageSortedHoster = grep(HosterList, ( "data-lang-key=\"" + std::to_string(LangId) + "\"" ) );
|
||||
//std::cout << "Alle Folgen mi der Sprache " << langId << ":\n'" << LanguageSortedHoster << "'" << std::endl;
|
||||
|
||||
//Wenn keine Links zu der Sprache gefunden worden sind
|
||||
if(LanguageSortedHoster == "")
|
||||
continue;
|
||||
|
||||
//Für jeden Angegebenen Hoster:
|
||||
while (getline(SListHoster, hoster).good()) {
|
||||
//Wenn es den hoster bei dieser prache nicht gibt, wähle nächsten
|
||||
if(LanguageSortedHoster.find("hoster=\"" + hoster + "\"") == std::string::npos) {
|
||||
//std::cout << "Hoster " << hoster << " gibt es bei der sprache" << langId << " nicht " << std::endl;
|
||||
continue;
|
||||
}
|
||||
Line = grep(LanguageSortedHoster, ("hoster=\"" + hoster + "\"" ) );
|
||||
pos = Line.find("href=\"");
|
||||
if(pos == std::string::npos) {
|
||||
std::cout << "Error: Konnte 'href=\"' in chooseHosterLink() nicht finden." << std::endl;
|
||||
continue;
|
||||
}
|
||||
Line.erase(0, pos + static_cast<int>(strlen("href=\"")));
|
||||
|
||||
pos = Line.find("\"");
|
||||
if(pos == std::string::npos) {
|
||||
std::cout << "Error: Konnte '\"' in chooseHosterLink() nicht finden." << std::endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
return Line.erase(pos, Line.length()-pos);
|
||||
}
|
||||
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,55 +0,0 @@
|
||||
#ifndef MANAGEPAGE_H
|
||||
#define MANAGEPAGE_H
|
||||
|
||||
#include "accountManager.h"
|
||||
|
||||
|
||||
#include "curl/curl.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <sstream>
|
||||
#include <unistd.h>
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
struct Reply {
|
||||
Reply() {}
|
||||
Reply(std::string value_both) : html(value_both), url(value_both) {}
|
||||
Reply(std::string html, std::string url) : html(html), url(url) {}
|
||||
|
||||
std::string html, url;
|
||||
};
|
||||
|
||||
|
||||
class PageManager
|
||||
{
|
||||
public:
|
||||
PageManager(std::string sock5Proxy = "socks5://127.0.0.1:9150", std::string cookieFilePath = "/tmp/S_New4_cookies");
|
||||
~PageManager();
|
||||
|
||||
void setProxy(std::string ip, int port);
|
||||
void setCookieFilePath(std::string path);
|
||||
void setDebugMode(bool status);
|
||||
|
||||
Reply getServerRequest(std::string Url, bool useCookies = false, std::string data = "", bool generateCookieFile = false);
|
||||
int login(Account account);
|
||||
std::string getUrlAfterRedirect(std::string Url);
|
||||
std::string checkName(std::string Name);
|
||||
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);
|
||||
|
||||
std::string replace(std::string str, std::string substr1, std::string substr2);
|
||||
int counterContains(std::string text, std::string substring_with_prozent_i_for_number, int starte_mit_dieser_Zahl = 1);
|
||||
std::string grep(std::string text, std::string substring, bool IgnoreCaseSensetifity = false);
|
||||
std::string upper_string(const std::string& str);
|
||||
|
||||
int writeToFile(std::string path, std::string text);
|
||||
|
||||
const std::string UrlPraefix = "https://s.to/serie/stream/";
|
||||
std::string sock5Proxy;
|
||||
private:
|
||||
std::string cookieFilePath;
|
||||
bool debugMode = false;
|
||||
};
|
||||
|
||||
#endif // MANAGEPAGE_H
|
@ -1,973 +0,0 @@
|
||||
#include "parameterManager.h"
|
||||
|
||||
void setPaths(Settings &settings)
|
||||
{
|
||||
//Path settings
|
||||
std::string executablePathTo = getexepath();
|
||||
|
||||
executablePathTo.erase(executablePathTo.find_last_of(settings.pathSymbol) + 1 , executablePathTo.length() - ( executablePathTo.find_last_of(settings.pathSymbol) + 1) );
|
||||
|
||||
if(!dirExists(executablePathTo + "src" + settings.pathSymbol)) {
|
||||
if(system(std::string("mkdir \"" + executablePathTo + "src" + settings.pathSymbol + "\"").c_str()) == 0)
|
||||
std::cout << " => Erfolgreich Ordner 'src' erstellt." << std::endl;
|
||||
else
|
||||
std::cout << " => Error: Ordner '" << executablePathTo << "src' konnte nicht erstellt werden." << std::endl;
|
||||
}
|
||||
if(dirExists(executablePathTo + "src" + settings.pathSymbol))
|
||||
executablePathTo+="src" + std::string(1, settings.pathSymbol);
|
||||
|
||||
settings.cookieFilePath = executablePathTo + "S_New4_cookies";
|
||||
settings.accountFilePath = executablePathTo + "Accounts";
|
||||
settings.accountNumberPath = executablePathTo + "Account_Number";
|
||||
settings.serienListPath = executablePathTo + "SerienListe";
|
||||
settings.defaultsFilePath = executablePathTo + "Defaults";
|
||||
|
||||
}
|
||||
|
||||
int manageParameter(Settings &settings, int argc, char **argv)
|
||||
{
|
||||
//Path settings
|
||||
setPathSymbol(settings);
|
||||
setPaths(settings);
|
||||
if(loadDefaulOptions(settings) != 0)
|
||||
return 28;
|
||||
|
||||
if(argc < 2) {
|
||||
std::cout << " => Error: Keine Unteroption angegeben." << std::endl;
|
||||
std::cout << "Aufruf: " << getProgramName() << " [Unteroption] [PARAMETER]" << std::endl;
|
||||
std::cout << "„" << getProgramName() << " --help“ liefert weitere Informationen." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int res = compare("--help\ndefault\nurl\n--version\nsearch\ninfo\nclean", argv[1]);
|
||||
if(res != 1) {
|
||||
std::cout << " => Error: " << ( (res == 0) ? std::string("Unbekannte Unteroption: '") + argv[1] + "'" :
|
||||
std::string("Mehrere Optionen für '") + argv[1] + std::string("' gefunden.") ) << std::endl;
|
||||
std::cout << "Aufruf: " << getProgramName() << " [Unteroption] [PARAMETER]" << std::endl;
|
||||
std::cout << "„" << getProgramName() << " --help“ liefert weitere Informationen." << std::endl;
|
||||
return 2;
|
||||
}
|
||||
|
||||
if(strncmp(argv[1], "--help", strlen(argv[1])) == 0) {
|
||||
argv[1][0] = '\0';
|
||||
return unterOption_help();
|
||||
|
||||
} else if (strncmp(argv[1], "default", strlen(argv[1])) == 0) {
|
||||
argv[1][0] = '\0';
|
||||
return unterOption_default(&settings, argc, argv);
|
||||
|
||||
} else if (strncmp(argv[1], "url", strlen(argv[1])) == 0) {
|
||||
argv[1][0] = '\0';
|
||||
return unterOption_url(&settings, argc, argv);
|
||||
|
||||
} else if (strncmp(argv[1], "--version", strlen(argv[1])) == 0) {
|
||||
std::cout << "Version: " << settings.version << std::endl;
|
||||
return -1;
|
||||
|
||||
} else if (strncmp(argv[1], "search", strlen(argv[1])) == 0) {
|
||||
argv[1][0] = '\0';
|
||||
return unterOption_search(&settings, argc, argv);
|
||||
|
||||
} else if (strncmp(argv[1], "info", strlen(argv[1])) == 0) {
|
||||
argv[1][0] = '\0';
|
||||
return unterOption_info(&settings, argc, argv);
|
||||
|
||||
} else if (strncmp(argv[1], "clean", strlen(argv[1])) == 0) {
|
||||
argv[1][0] = '\0';
|
||||
unterOption_clean(&settings, argc, argv);
|
||||
return -1;
|
||||
|
||||
} else {
|
||||
std::cout << "Error: Invalid option " << argv[1] << ", but not detected in compare-Function" << std::endl;
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
|
||||
int loadDefaulOptions(Settings &settings)
|
||||
{
|
||||
std::fstream ifs(settings.defaultsFilePath);
|
||||
if(!ifs.is_open()) {
|
||||
std::ofstream ofs(settings.defaultsFilePath);
|
||||
if(!ofs.is_open()) {
|
||||
std::cout << " => Error: Konnte Defaults-Datei nicht öffnen: " << errno << std::endl;
|
||||
return 89;
|
||||
} else {
|
||||
std::cout << " => Erstelle Defaults-Datei: " << settings.defaultsFilePath << std::endl;
|
||||
ofs << "#Mit # kann man eine Zeile deaktivieren." << std::endl;
|
||||
ofs << "DefaultFileVersion="<< settings.defaultFileVersion << std::endl;
|
||||
ofs << "#DebugModus=false" << std::endl;
|
||||
ofs << std::endl;
|
||||
ofs << "#Socks5Proxy=127.0.0.1:9050" << std::endl;
|
||||
ofs << "#FarbloseAusgabe=false" << std::endl;
|
||||
ofs << "#OutputFile=/tmp/a" << std::endl;
|
||||
ofs << std::endl;
|
||||
ofs << "#default-GenaueHoster=Vivo,GoUnlimited" << std::endl;
|
||||
ofs << "#default-Sprachen=GerDub,GerSub,Eng" << std::endl;
|
||||
ofs << "#default-CheckSuchMuster=S%Staffel%E%Folge%" << std::endl;
|
||||
ofs << "#default-CheckMaxDirs=20" << std::endl;
|
||||
ofs << "#default-maxThreads=0" << std::endl;
|
||||
ofs << std::endl;
|
||||
ofs << "#search-AchteAufGroßUndKleinschreibung=false" << std::endl;
|
||||
|
||||
|
||||
ofs.close();
|
||||
}
|
||||
ifs.open(settings.defaultsFilePath);
|
||||
if(!ifs.is_open()) {
|
||||
std::cout << " => Error: Konnte Defaults-Datei nach dem erstellen nicht öffnen: " << errno << std::endl;
|
||||
return 97;
|
||||
}
|
||||
}
|
||||
|
||||
std::string line;
|
||||
while (std::getline(ifs, line).good()) {
|
||||
if(line.find("#") != std::string::npos || line == "")
|
||||
continue;
|
||||
else if ( line.find("=") == std::string::npos ) {
|
||||
std::cout << " => Warnung: Bitte Info-Texte mit '#' am Anfang: Ungültige Option '" << line << "'." << std::endl;
|
||||
continue;
|
||||
}
|
||||
std::string what = line.substr(0, line.find("=")), data = line.substr(line.find("=") + 1, line.length() - line.find("=") -1);
|
||||
if(what == "") {
|
||||
|
||||
} else if (what == "Socks5Proxy") { ///---
|
||||
if(data.find(":") == std::string::npos) {
|
||||
std::cout << " => Error_Defaults: Ungültiger Socks5 Proxy: '" << data << "'" << std::endl;
|
||||
return 31;
|
||||
}
|
||||
std::string ip = data.substr(0, data.find(":"));
|
||||
std::string portStr = data.substr(data.find(":") + 1, data.length() - data.find(":"));
|
||||
int port = atoi(portStr.c_str());
|
||||
if(std::to_string(port) != portStr || port <= 0) {
|
||||
std::cout << " => Error_Defaults: Socks5 Proxy: Invalid Port: " << portStr << std::endl;
|
||||
return 32;
|
||||
} else if (ip == "") {
|
||||
std::cout << " => Error_Defaults: Socks5 Proxy: Invalid Ip Addresse: " << ip << std::endl;
|
||||
return 34;
|
||||
} else if(settings.debugMode) {
|
||||
std::cout << " > Defaults: Proxy Addresse: "<< ip << ":" << port << std::endl;
|
||||
}
|
||||
settings.proxy_ip = ip;
|
||||
settings.proxy_port = port;
|
||||
|
||||
} else if (what == "DefaultFileVersion") { ///---
|
||||
if(data != settings.defaultFileVersion)
|
||||
std::cout << " => Warnung: Veraltetes Defaults-File. Löschen sie die Datei, um die neuste Version zu bekommen." << std::endl;
|
||||
|
||||
} else if (what == "DebugModus") { ///---
|
||||
if(data == "true")
|
||||
settings.debugMode=true;
|
||||
else if (data == "false")
|
||||
settings.debugMode=false;
|
||||
else {
|
||||
std::cout << " => Error_Defaults: DebugModus: Ungültiger Wert für 'true/false': " << data << std::endl;
|
||||
return 161;
|
||||
}
|
||||
if(settings.debugMode)
|
||||
std::cout << " > Defaults: DebugMode: true" << std::endl;
|
||||
|
||||
} else if (what == "default-GenaueHoster") {
|
||||
settings.genaueHoster=data;
|
||||
if(settings.debugMode)
|
||||
std::cout << " > Defaults: GenaueHoster: " << settings.genaueHoster << std::endl;
|
||||
|
||||
} else if (what == "default-Sprachen") {
|
||||
settings.languages=data;
|
||||
if(settings.debugMode)
|
||||
std::cout << " > Defaults: Sprachen: " << settings.languages << std::endl;
|
||||
|
||||
} else if (what == "default-CheckSuchMuster") {
|
||||
settings.default_Searchmuster=data;
|
||||
if(settings.debugMode)
|
||||
std::cout << " > Defaults: SuchMuster: " << settings.default_Searchmuster << std::endl;
|
||||
|
||||
} else if (what == "default-CheckMaxDirs") {
|
||||
settings.default_maxDirs = atoi(data.c_str());
|
||||
if(std::to_string(settings.default_maxDirs) != data ) {
|
||||
std::cout << " => Error_Defaults: default-CheckMaxDirs: Ungültige Zahl: " << data << std::endl;
|
||||
return 18;
|
||||
}
|
||||
if(settings.debugMode)
|
||||
std::cout << " > Defaults: default-CheckMaxDirs: " << settings.default_maxDirs << std::endl;
|
||||
|
||||
|
||||
} else if (what == "default-maxThreads") {
|
||||
settings.maxThreads = static_cast<unsigned>(atoi(data.c_str()));
|
||||
if(std::to_string(settings.maxThreads) != data ) {
|
||||
std::cout << " => Error_Defaults: Ungültige Zahl: " << data << std::endl;
|
||||
return 18;
|
||||
}
|
||||
if(settings.debugMode)
|
||||
std::cout << " > Defaults: MaxThreads: " << settings.maxThreads << std::endl;
|
||||
|
||||
} else if (what == "FarbloseAusgabe") {
|
||||
if(data == "true")
|
||||
settings.colorless=true;
|
||||
else if (data == "false")
|
||||
settings.colorless=false;
|
||||
else {
|
||||
std::cout << " => Error_Defaults: FarbloseAusgabe: Ungültiger Wert für 'true/false': " << data << std::endl;
|
||||
return 207;
|
||||
}
|
||||
if(settings.debugMode)
|
||||
std::cout << " > Defaults: FarbloseAusgabe: " << settings.colorless << std::endl;
|
||||
|
||||
} else if (what == "search-AchteAufGroßUndKleinschreibung") {
|
||||
if(data == "true")
|
||||
settings.search_IgnoreUpperLower=false;
|
||||
else if (data == "false")
|
||||
settings.search_IgnoreUpperLower=true;
|
||||
else {
|
||||
std::cout << " => Error_Defaults: search-AchteAufGroßUndKleinschreibung: Ungültiger Wert für 'true/false': " << data << std::endl;
|
||||
return 227;
|
||||
}
|
||||
if(settings.debugMode)
|
||||
std::cout << " > Defaults: search-AchteAufGroßUndKleinschreibung: " << settings.search_IgnoreUpperLower << std::endl;
|
||||
|
||||
} else if (what == "OutputFile") {
|
||||
settings.outputFilePath = data;
|
||||
if(settings.debugMode)
|
||||
std::cout << " > Defaults: OutputFile: " << settings.outputFilePath << std::endl;
|
||||
|
||||
} else if (what == "") {
|
||||
|
||||
} else if (what == "") {
|
||||
|
||||
} else if (what == "") {
|
||||
|
||||
} else if (what == "") {
|
||||
|
||||
} else {
|
||||
std::cout << " => Warnung: Unbekannte Default-Option: '" << what << "'." << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ifs.close();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int unterOption_help()
|
||||
{
|
||||
std::cout << "Aufruf: " << getProgramName() << " [Unteroption] [PARAMETER]..." << std::endl << std::endl;
|
||||
std::cout << "Beschreibung:" << std::endl
|
||||
<< " -> Mit diesem Programm kann man die Download-Urls" << std::endl
|
||||
<< " oder Informationen von Serien bekommen." << std::endl
|
||||
<< " -> Mit diesem Programm kann man Redirect-Links von" << std::endl
|
||||
<< " s.to umwandeln." << std::endl
|
||||
<< std::endl;
|
||||
|
||||
std::cout << "Unteroptionen:" << std::endl
|
||||
<< "\t„--help“\tGibt dieses Helpmenue aus." << std::endl
|
||||
<< "\t„--version“\tGibt die Version des Programmes aus." << std::endl
|
||||
<< "\t„url“\t\tModus um eigene Redirect-Links umzuwandeln." << std::endl
|
||||
<< "\t„default“\tModus um Links von Serien zu bekommen." << std::endl
|
||||
<< "\t„search“\tModus um Serien zu suchen." << std::endl
|
||||
<< "\t„info“\t\tModus um Infos einer Serien zu bekommen." << std::endl
|
||||
<< "\t„clean“\t\tModus um Cookie-Files zu löschen." << std::endl;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
int unterOption_default(Settings *settings, int argc, char ** argv)
|
||||
{
|
||||
settings->modus = Modus::DEFAULT_MODUS;
|
||||
|
||||
int c = 0;
|
||||
const option long_opts[] = {
|
||||
{"socks5-proxy", required_argument, nullptr, 'p'},
|
||||
{"genauer-hoster", required_argument, nullptr, 'g'},
|
||||
{"languages", required_argument, nullptr, 'l'},
|
||||
{"output-file", required_argument, nullptr, 'o'},
|
||||
|
||||
{"start-episode", required_argument, nullptr, 'e'},
|
||||
{"stop-episode", required_argument, nullptr, 'E'},
|
||||
{"start-season", required_argument, nullptr, 's'},
|
||||
{"stop-season", required_argument, nullptr, 'S'},
|
||||
|
||||
{"check-dir", required_argument, nullptr, 'C'},
|
||||
{"check-muster", required_argument, nullptr, 'm'},
|
||||
{"check-max-dirs", required_argument, nullptr, 'D'},
|
||||
|
||||
{"threads", required_argument, nullptr, 't'},
|
||||
|
||||
{"help", no_argument, nullptr, 'h'},
|
||||
{"colorless", no_argument, nullptr, 'c'},
|
||||
{"debug-mode", no_argument, nullptr, 'd'},
|
||||
|
||||
{nullptr, no_argument, nullptr, 0}
|
||||
|
||||
};
|
||||
|
||||
while( ( c = getopt_long (argc, argv, "p:g:l:o:e:E:s:S:C:m:D:t:hcd", long_opts, nullptr) ) != -1 ) {
|
||||
switch(c) {
|
||||
case 'p': {
|
||||
if(!optarg || std::string(optarg) == "")
|
||||
break;
|
||||
std::string optarg = ::optarg;
|
||||
if(optarg.find(":") == std::string::npos) {
|
||||
std::cout << "Invalid Socks5 Proxy: " << optarg << std::endl;
|
||||
return 31;
|
||||
}
|
||||
std::string ip = optarg.substr(0, optarg.find(":"));
|
||||
std::string portStr = optarg.substr(optarg.find(":") + 1, optarg.length() - optarg.find(":"));
|
||||
int port = atoi(portStr.c_str());
|
||||
if(std::to_string(port) != portStr || port <= 0) {
|
||||
std::cout << "[-p]: Invalid Port: " << portStr << std::endl;
|
||||
return 32;
|
||||
} else if (ip == "") {
|
||||
std::cout << "[-p]: Invalid Ip Addresse: " << ip << std::endl;
|
||||
return 34;
|
||||
} else if(settings->debugMode) {
|
||||
std::cout << "Proxy Addresse: "<< ip << ":" << port << std::endl;
|
||||
}
|
||||
settings->proxy_ip = ip;
|
||||
settings->proxy_port = port;
|
||||
}
|
||||
break;
|
||||
case 'g':
|
||||
if(optarg)
|
||||
settings->genaueHoster =+ optarg + std::string(",");
|
||||
if(settings->debugMode)
|
||||
std::cout << "Hosterreihenfolge: " << settings->genaueHoster << std::endl;
|
||||
break;
|
||||
case 'l':
|
||||
if(optarg)
|
||||
settings->languages =+ optarg + std::string(",");
|
||||
if(settings->debugMode)
|
||||
std::cout << "Sprachenreihenfolge: " << settings->languages << std::endl;
|
||||
break;
|
||||
case 'o':
|
||||
if(optarg)
|
||||
settings->outputFilePath = optarg;
|
||||
if(settings->debugMode)
|
||||
std::cout << "Pfad zu Output-Datei: " << settings->outputFilePath << std::endl;
|
||||
break;
|
||||
|
||||
case 'e':
|
||||
if(!optarg)
|
||||
break;
|
||||
settings->startEpisode = atoi(optarg);
|
||||
if (std::to_string(settings->startEpisode) != optarg) {
|
||||
std::cout << "Error: -e [Folge]: '" << optarg << "' ist keine Zahl." << std::endl;
|
||||
return 11;
|
||||
} else if (settings->startEpisode == 0) {
|
||||
std::cout << "Error: -e [Folge]: StartEpisode ist 0." << std::endl;
|
||||
return 12;
|
||||
} else if (settings->startEpisode < 0) {
|
||||
std::cout << "Error: -e [Folge]: StartEpisode " << settings->startEpisode << " ist kleiner 0." << std::endl;
|
||||
return 13;
|
||||
}
|
||||
if(settings->debugMode)
|
||||
std::cout << "StartEpisode: " << settings->startEpisode << std::endl;
|
||||
break;
|
||||
case 'E':
|
||||
if(!optarg)
|
||||
break;
|
||||
settings->stopEpisode = atoi(optarg);
|
||||
if (std::to_string(settings->stopEpisode) != optarg) {
|
||||
std::cout << "Error: -E [Folge]: '" << optarg << "' ist keine Zahl." << std::endl;
|
||||
return 14;
|
||||
} else if (settings->debugMode)
|
||||
std::cout << "StopEpisode: " << settings->stopEpisode << std::endl;
|
||||
break;
|
||||
case 's':
|
||||
if(!optarg)
|
||||
break;
|
||||
settings->startSeason = atoi(optarg);
|
||||
if (std::to_string(settings->startSeason) != optarg) {
|
||||
std::cout << "Error: -s [Staffel]: '" << optarg << "' ist keine Zahl." << std::endl;
|
||||
return 15;
|
||||
} else if (settings->startSeason == 0) {
|
||||
std::cout << "Error: -s [Staffel]: StartStaffel ist 0." << std::endl;
|
||||
return 16;
|
||||
} else if (settings->startSeason < 0) {
|
||||
std::cout << "Error: -s [Staffel]: StartStaffel " << settings->startSeason << " ist kleiner 0." << std::endl;
|
||||
return 17;
|
||||
} else if(settings->debugMode)
|
||||
std::cout << "StartStaffel: " << settings->startSeason << std::endl;
|
||||
break;
|
||||
case 'S':
|
||||
if(!optarg)
|
||||
break;
|
||||
settings->stopSeason = atoi(optarg);
|
||||
if (std::to_string(settings->stopSeason) != optarg) {
|
||||
std::cout << "Error: -S [Staffel]: '" << optarg << "' ist keine Zahl." << std::endl;
|
||||
return 18;
|
||||
} else if(settings->debugMode)
|
||||
std::cout << "StopSeason: " << settings->stopSeason << std::endl;
|
||||
break;
|
||||
case 'm':
|
||||
if(optarg)
|
||||
settings->default_Searchmuster = optarg;
|
||||
if(settings->debugMode)
|
||||
std::cout << " SearchMuster: " << settings->default_Searchmuster << std::endl;
|
||||
break;
|
||||
case 'D':
|
||||
if(!optarg)
|
||||
break;
|
||||
settings->default_maxDirs = atoi(optarg);
|
||||
if(std::to_string(settings->default_maxDirs) != std::string(optarg) ) {
|
||||
std::cout << "[-D]: Invalid Count: " << optarg << std::endl;
|
||||
return 18;
|
||||
}
|
||||
if(settings->debugMode)
|
||||
std::cout << "CheckMaxDirs: " << settings->default_maxDirs << std::endl;
|
||||
|
||||
break;
|
||||
case 't':
|
||||
if(!optarg)
|
||||
break;
|
||||
settings->maxThreads = static_cast<unsigned>(atoi(optarg));
|
||||
if(std::to_string(settings->maxThreads) != std::string(optarg) ) {
|
||||
std::cout << "[-t]: Ungültige Zahl: " << optarg << std::endl;
|
||||
return 18;
|
||||
}
|
||||
if(settings->debugMode)
|
||||
std::cout << "MaxThreads: " << settings->maxThreads << std::endl;
|
||||
|
||||
break;
|
||||
|
||||
case 'C':
|
||||
if(!optarg)
|
||||
break;
|
||||
settings->default_checkDirPath = optarg;
|
||||
if(settings->debugMode)
|
||||
std::cout << "To check Dir: " << settings->default_checkDirPath << std::endl;
|
||||
break;
|
||||
case 'c':
|
||||
settings->colorless = true;
|
||||
if(settings->debugMode)
|
||||
std::cout << "Farblos: true" << std::endl;
|
||||
if(argc > optind)
|
||||
if(argv[optind][0] != '-' && std::string(argv[optind]).find(settings->pathSymbol) != std::string::npos) {
|
||||
std::cout << " => Upps: Hast du -c (--colorless) mit -C (--check-dir) verwechselt?" << std::endl
|
||||
<< " (Hat “Argument“ mit “"<< settings->pathSymbol << "“: '-c " << std::string(argv[optind]) << "')." << std::endl;
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
case 'd':
|
||||
settings->debugMode = true;
|
||||
if(settings->debugMode)
|
||||
std::cout << "Debug Modus: true" << std::endl;
|
||||
break;
|
||||
case 'h':
|
||||
unterOption_default_help();
|
||||
return -1;
|
||||
default:
|
||||
std::cout << "Aufruf: " << getProgramName() << " default [OPTION]... [NAME]..." << std::endl;
|
||||
std::cout << "„" << getProgramName() << " default --help“ liefert weitere Informationen." << std::endl;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
//Alle nicht verwendeten Parameter == Name
|
||||
while (optind < argc) {
|
||||
if(argv[optind][0]) {
|
||||
settings->name.append(argv[optind++]).append(" ");
|
||||
} else
|
||||
optind++;
|
||||
}
|
||||
|
||||
if(settings->name.length() > 0)
|
||||
settings->name.pop_back();
|
||||
if(settings->debugMode) {
|
||||
std::cout << "Name: " << settings->name << std::endl;
|
||||
std::cout << "Modus: DEFAULT_MODUS" << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void unterOption_default_help()
|
||||
{
|
||||
std::cout << "Usage: " << getProgramName() << " default [OPTION]... [NAME]..." << std::endl
|
||||
<< "Parameter:" << std::endl << std::endl
|
||||
<< " > Auswahloptionen:" << std::endl
|
||||
<< "\t-g [Hoster1,Hoster2,...], --genauer-hoster [Hoster1,Hoster2,...]" << std::endl
|
||||
<< "\t -> Die Namen der Hoster, deren Links du willst. Der wichtigste zuerst." << std::endl
|
||||
<< "\t -> Default: Vivo,GoUnlimited" << std::endl
|
||||
<< "\t-l [GerDub/GerSub/Eng,...], --languages [GerDub/GerSub/Eng,...]" << std::endl
|
||||
<< "\t -> Die Sprache(n) die du willst. Die wichtigsten zuerst. Default: GerDub,GerSub,Eng" << std::endl
|
||||
<< std::endl
|
||||
<< " > Proxy-Optionen:" << std::endl
|
||||
<< "\t-p [ProxyAddresse], --socks5-proxy [ProxyAddresse]" << std::endl
|
||||
<< "\t -> Ip Addresse eines Socks5-Proxys angeben. Default: 127.0.0.1:9050" << std::endl
|
||||
<< std::endl
|
||||
<< " > Outputoptionen:" << std::endl
|
||||
<< "\t-o [Pfad], --output-file [Pfad]" << std::endl
|
||||
<< "\t -> Schreibe Links nach Redirect in diese Datei." << std::endl
|
||||
<< "\t-c, --colorless" << std::endl
|
||||
<< "\t -> Keine Farben beim Output verwenden. Default: false" << std::endl
|
||||
<< "\t-d, --debug-mode" << std::endl
|
||||
<< "\t -> Debug Nachrichten an. Default: false" << std::endl
|
||||
<< std::endl
|
||||
<< " > Check-Dir Optionen:" << std::endl
|
||||
<< "\t-C [Pfad], --check-dir [Pfad]" << std::endl
|
||||
<< "\t -> Überprüfe ob in diesem, oder in einen der Unterordnern die Folge vorkommt." << std::endl
|
||||
<< "\t -> Wenn ja, dann überspringe diese." << std::endl
|
||||
<< "\t-m, --check-muster" << std::endl
|
||||
<< "\t -> Muster mit dem Überprüft wird, ob diese Folge in einem Ordner ist. Default: S%Staffel%E%Folge%" << std::endl
|
||||
<< "\t -> %Staffel% ist eine Variable für die Staffel mit 0 + Staffel, wenn Staffel < 10. " << std::endl
|
||||
<< "\t -> %Folge% ist eine Variable für die Folge mit 0 + Folge, wenn Folge < 10. " << std::endl
|
||||
<< "\t-D, --check-max-dirs" << std::endl
|
||||
<< "\t -> Maximale Anzahl der Ordner, die auf Dateien untersucht werden. Default: 20" << std::endl
|
||||
<< std::endl
|
||||
<< " > Durchlaufoptionen:" << std::endl
|
||||
<< "\t-e [Folge], --start-episode [Folge]" << std::endl
|
||||
<< "\t -> Das Programm startet mit dieser Folge." << std::endl
|
||||
<< "\t Default: 1" << std::endl
|
||||
<< "\t-E [Folge], --stop-episode [Folge]" << std::endl
|
||||
<< "\t -> - Wenn -S nicht verwendet wird, stoppt das Programm sobald die Folge erreicht wurde." << std::endl
|
||||
<< "\t - Wenn -S verwendet wird, stoppt es 1. wenn die Folge UND die Staffel erreicht wurden," << std::endl
|
||||
<< "\t 2. wenn die die Staffel von -S fertig ist. Zum deaktivieren Folge <= 0 verwenden." << std::endl
|
||||
<< "\t Default: 0" << std::endl
|
||||
<< "\t-s [Staffel], --start-season [Staffel]" << std::endl
|
||||
<< "\t -> Das Programm startet mit dieser Staffel." << std::endl
|
||||
<< "\t Default: 1" << std::endl
|
||||
<< "\t-S [Staffel], --stop-season [Staffel]" << std::endl
|
||||
<< "\t -> Das Programm stopt mit dieser Staffel. Beachte Verwendung mit -E." << std::endl
|
||||
<< "\t Zum deaktivieren Staffel <= 0 verwenden. Default: 0" << std::endl
|
||||
<< " > Multi-Thrading Optionen:" << std::endl
|
||||
<< "\t-t [maxThreads], --threads [maxThreads]" << std::endl
|
||||
<< "\t -> Das Programm startet für jede Folge einen eigenen Thread," << std::endl
|
||||
<< "\t -> bis die maximale Anzahl ereicht wurde. Dann wartet es auf" << std::endl
|
||||
<< "\t -> das enden aller Threads und fängt dann wieder von vorne an." << std::endl
|
||||
<< "\t -> Zum deaktivieren von Multithreading '0' verwenden. Default: 0" << std::endl
|
||||
<< std::endl
|
||||
<< " > Help-Optionen" << std::endl
|
||||
<< "\t-h, --help" << std::endl;
|
||||
|
||||
}
|
||||
|
||||
|
||||
int unterOption_url(Settings *settings, int argc, char **argv)
|
||||
{
|
||||
settings->modus = Modus::DIRECT_LINK_MODUS;
|
||||
|
||||
int c = 0;
|
||||
const option long_opts[] = {
|
||||
{"socks5-proxy", required_argument, nullptr, 'p'},
|
||||
{"output-file", required_argument, nullptr, 'o'},
|
||||
|
||||
{"help", no_argument, nullptr, 'h'},
|
||||
{"colorless", no_argument, nullptr, 'c'},
|
||||
{"debug-mode", no_argument, nullptr, 'd'},
|
||||
|
||||
{nullptr, no_argument, nullptr, 0}
|
||||
|
||||
};
|
||||
|
||||
while( ( c = getopt_long (argc, argv, "p:o:hcd", long_opts, nullptr) ) != -1 ) {
|
||||
switch(c) {
|
||||
case 'p': {
|
||||
if(!optarg || std::string(optarg) == "")
|
||||
break;
|
||||
std::string optarg = ::optarg;
|
||||
if(optarg.find(":") == std::string::npos) {
|
||||
std::cout << "Invalid Socks5 Proxy: " << optarg << std::endl;
|
||||
return 31;
|
||||
}
|
||||
std::string ip = optarg.substr(0, optarg.find(":"));
|
||||
std::string portStr = optarg.substr(optarg.find(":") + 1, optarg.length() - optarg.find(":"));
|
||||
int port = atoi(portStr.c_str());
|
||||
if(std::to_string(port) != portStr || port <= 0) {
|
||||
std::cout << "[-p]: Invalid Port: " << portStr << std::endl;
|
||||
return 32;
|
||||
} else if (ip == "") {
|
||||
std::cout << "[-p]: Invalid Ip Addresse: " << ip << std::endl;
|
||||
return 34;
|
||||
} else if(settings->debugMode) {
|
||||
std::cout << "Proxy Addresse: "<< ip << ":" << port << std::endl;
|
||||
}
|
||||
settings->proxy_ip = ip;
|
||||
settings->proxy_port = port;
|
||||
}
|
||||
break;
|
||||
case 'o':
|
||||
if(optarg)
|
||||
settings->outputFilePath = optarg;
|
||||
if(settings->debugMode)
|
||||
std::cout << "Pfad zu Output-Datei: " << settings->outputFilePath << std::endl;
|
||||
break;
|
||||
case 'c':
|
||||
settings->colorless = true;
|
||||
if(settings->debugMode)
|
||||
std::cout << "Farblos: true" << std::endl;
|
||||
break;
|
||||
case 'd':
|
||||
settings->debugMode = true;
|
||||
if(settings->debugMode)
|
||||
std::cout << "Debug Modus: true" << std::endl;
|
||||
break;
|
||||
case 'h':
|
||||
unterOption_url_help();
|
||||
return -1;
|
||||
default:
|
||||
std::cout << "Aufruf: " << getProgramName() << " url [OPTION]... [URL]..." << std::endl;
|
||||
std::cout << "„" << getProgramName() << " url --help“ liefert weitere Informationen." << std::endl;
|
||||
return 21;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Alle nicht verwendeten Parameter == Name
|
||||
while (optind < argc) {
|
||||
if(argv[optind][0]) {
|
||||
settings->name.append(argv[optind++]).append(",");
|
||||
} else
|
||||
optind++;
|
||||
}
|
||||
|
||||
if(settings->name.length() > 0)
|
||||
settings->name.pop_back();
|
||||
if(settings->debugMode) {
|
||||
std::cout << "Urls: " << settings->name << std::endl;
|
||||
std::cout << "Modus: DIRECT_LINK_MODUS" << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void unterOption_url_help()
|
||||
{
|
||||
std::cout << "Aufruf: " << getProgramName() << "url [OPTION]... [URL]..." << std::endl << std::endl;
|
||||
|
||||
std::cout << "Beschreibung:" << std::endl
|
||||
<< " Mit dieser Unterfunction von " << getProgramName() << " können eigene" << std::endl
|
||||
<< " Redirect-Links umgewandelt werden. Beispiel:" << std::endl
|
||||
<< " https://s.to/redirect/4449825 -> http://vivo.sx/d20b111ade" << std::endl
|
||||
<< " Achtung: Achte, dass Url mit https:// nicht mit http:// beginnt." << std::endl
|
||||
<< " Standartwerte können im Defaultfile geändert werden." << std::endl << std::endl;
|
||||
|
||||
std::cout << "OPTIONEN:" << std::endl
|
||||
|
||||
<< " -p [Socks5ProxyAddresse], --socks5-proxy [Socks5ProxyAddresse]" << std::endl
|
||||
<< " Mit dieser Option kann man den Socks5Proxy ändern." << std::endl
|
||||
<< " Standart: 127.0.0.1:9050, falls nichts im Defaultfile festgelegt wurde." << std::endl << std::endl
|
||||
<< " -o [Pfad], --output-file [Pfad]" << std::endl
|
||||
<< " Mit diere Option kann man ein (nichtvorhandenes) Text-Datei angeben," << std::endl
|
||||
<< " inwelches die umgewandelten Redirect-Links geschrieben werden." << 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
|
||||
<< " Mit dieser Option kann man den Debug-Modus einschalten." << std::endl
|
||||
<< " Dabei werden vielmehr Infos ausgegeben." << std::endl << std::endl
|
||||
<< " -h, --help" << std::endl
|
||||
<< " Mit dieser Option wird dieses Helpmenue ausgegeben." << std::endl;
|
||||
}
|
||||
|
||||
|
||||
int unterOption_search(Settings *settings, int argc, char **argv)
|
||||
{
|
||||
settings->modus = Modus::SEARCH_MODUS;
|
||||
|
||||
int c = 0;
|
||||
const option long_opts[] = {
|
||||
{"socks5-proxy", required_argument, nullptr, 'p'},
|
||||
|
||||
{"help", no_argument, nullptr, 'h'},
|
||||
{"colorless", no_argument, nullptr, 'c'},
|
||||
{"debug-mode", no_argument, nullptr, 'd'},
|
||||
{"exactly-writing", no_argument, nullptr, 'e'},
|
||||
{"update", no_argument, nullptr, 'u'},
|
||||
|
||||
{nullptr, no_argument, nullptr, 0}
|
||||
|
||||
};
|
||||
|
||||
while( ( c = getopt_long (argc, argv, "n:p:hcdeu", long_opts, nullptr) ) != -1 ) {
|
||||
switch(c) {
|
||||
case 'p': {
|
||||
if(!optarg || std::string(optarg) == "")
|
||||
break;
|
||||
std::string optarg = ::optarg;
|
||||
if(optarg.find(":") == std::string::npos) {
|
||||
std::cout << "Invalid Socks5 Proxy: " << optarg << std::endl;
|
||||
return 31;
|
||||
}
|
||||
std::string ip = optarg.substr(0, optarg.find(":"));
|
||||
std::string portStr = optarg.substr(optarg.find(":") + 1, optarg.length() - optarg.find(":"));
|
||||
int port = atoi(portStr.c_str());
|
||||
if(std::to_string(port) != portStr || port <= 0) {
|
||||
std::cout << "[-p]: Invalid Port: " << portStr << std::endl;
|
||||
return 32;
|
||||
} else if (ip == "") {
|
||||
std::cout << "[-p]: Invalid Ip Addresse: " << ip << std::endl;
|
||||
return 34;
|
||||
} else if(settings->debugMode) {
|
||||
std::cout << "Proxy Addresse: "<< ip << ":" << port << std::endl;
|
||||
}
|
||||
settings->proxy_ip = ip;
|
||||
settings->proxy_port = port;
|
||||
}
|
||||
break;
|
||||
case 'h':
|
||||
unterOption_search_help();
|
||||
return -1;
|
||||
case 'c':
|
||||
settings->colorless = true;
|
||||
if(settings->debugMode)
|
||||
std::cout << "Farblos: true" << std::endl;
|
||||
break;
|
||||
case 'd':
|
||||
settings->debugMode = true;
|
||||
if(settings->debugMode)
|
||||
std::cout << "Debug Modus: true" << std::endl;
|
||||
break;
|
||||
case 'e':
|
||||
settings->search_IgnoreUpperLower = false;
|
||||
if(settings->debugMode)
|
||||
std::cout << "Achte auf Groß und Kleinschreibung: true" << std::endl;
|
||||
break;
|
||||
case 'u':
|
||||
settings->search_wantUpdate = true;
|
||||
if(settings->debugMode)
|
||||
std::cout << "Update die Liste: true" << std::endl;
|
||||
break;
|
||||
default:
|
||||
std::cout << "Aufruf: " << getProgramName() << " search [OPTION]... [NAME]..." << std::endl;
|
||||
std::cout << "„" << getProgramName() << " search --help“ liefert weitere Informationen." << std::endl;
|
||||
return 21;
|
||||
}
|
||||
}
|
||||
|
||||
//Alle nicht verwendeten Parameter == Name
|
||||
while (optind < argc) {
|
||||
if(argv[optind][0]) {
|
||||
settings->name.append(argv[optind++]).append(" ");
|
||||
} else
|
||||
optind++;
|
||||
}
|
||||
if(settings->name.length() > 0)
|
||||
settings->name.pop_back();
|
||||
if(settings->debugMode) {
|
||||
std::cout << "Name: " << settings->name << std::endl;
|
||||
std::cout << "Modus: Search_MODUS" << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void unterOption_search_help()
|
||||
{
|
||||
std::cout << "Aufruf: " << getProgramName() << "search [OPTION]... [NAME]" << std::endl
|
||||
<< " " << getProgramName() << "search [-u, --update]" << std::endl << std::endl;
|
||||
|
||||
std::cout << "Beschreibung:" << std::endl
|
||||
<< " Mit dieser Unterfunction des Programms kann man Serien auf s.to suchen." << std::endl
|
||||
<< " Tipp: Falls deine Serie nicht gefunden wird, entferne einen Teil" << std::endl
|
||||
<< " am Ende deines SuchNamens und wiederhole die Suche." << std::endl
|
||||
<< " Tipp: Wenn deine Serie sehr neu auf s.to ist, und deshalb nicht gefunden" << std::endl
|
||||
<< " wird, verwende die Option -u, um die Liste zu aktualisieren." << std::endl << std::endl;
|
||||
|
||||
std::cout << "AKTUALISIERUNG:" << std::endl
|
||||
|
||||
<< " -u, --update" << std::endl
|
||||
<< " Mit dieser Option wird die Liste der Serien, die bei der Suche durchsucht " << std::endl
|
||||
<< " wird, aktualisiert." << std::endl << std::endl;
|
||||
|
||||
std::cout << "OPTIONEN:" << std::endl
|
||||
|
||||
<< " -p [Socks5ProxyAddresse], --socks5-proxy [Socks5ProxyAddresse]" << std::endl
|
||||
<< " Mit dieser Option kann man den Socks5Proxy ändern." << std::endl
|
||||
<< " Standart: 127.0.0.1:9050, falls nichts im Defaultfile festgelegt wurde." << std::endl << std::endl
|
||||
<< " -e, --exactly-writing" << std::endl
|
||||
<< " Mit dieser Option achtet das Programm auf Groß- und Kleinschreibung." << 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
|
||||
<< " Mit dieser Option kann man den Debug-Modus einschalten." << std::endl
|
||||
<< " Dabei werden vielmehr Infos ausgegeben." << std::endl << std::endl
|
||||
<< " -h, --help" << std::endl
|
||||
<< " Mit dieser Option wird dieses Helpmenue ausgegeben." << std::endl << std::endl;
|
||||
}
|
||||
|
||||
|
||||
int unterOption_info(Settings *settings, int argc, char **argv)
|
||||
{
|
||||
settings->modus = Modus::INFO_MODUS;
|
||||
|
||||
int c = 0;
|
||||
const option long_opts[] = {
|
||||
{"socks5-proxy", required_argument, nullptr, 'p'},
|
||||
|
||||
{"help", no_argument, nullptr, 'h'},
|
||||
{"colorless", no_argument, nullptr, 'c'},
|
||||
{"debug-mode", no_argument, nullptr, 'd'},
|
||||
|
||||
{nullptr, no_argument, nullptr, 0}
|
||||
|
||||
};
|
||||
|
||||
while( ( c = getopt_long (argc, argv, "n:p:hcdeu", long_opts, nullptr) ) != -1 ) {
|
||||
switch(c) {
|
||||
case 'p': {
|
||||
if(!optarg || std::string(optarg) == "")
|
||||
break;
|
||||
std::string optarg = ::optarg;
|
||||
if(optarg.find(":") == std::string::npos) {
|
||||
std::cout << "Invalid Socks5 Proxy: " << optarg << std::endl;
|
||||
return 31;
|
||||
}
|
||||
std::string ip = optarg.substr(0, optarg.find(":"));
|
||||
std::string portStr = optarg.substr(optarg.find(":") + 1, optarg.length() - optarg.find(":"));
|
||||
int port = atoi(portStr.c_str());
|
||||
if(std::to_string(port) != portStr || port <= 0) {
|
||||
std::cout << "[-p]: Invalid Port: " << portStr << std::endl;
|
||||
return 32;
|
||||
} else if (ip == "") {
|
||||
std::cout << "[-p]: Invalid Ip Addresse: " << ip << std::endl;
|
||||
return 34;
|
||||
} else if(settings->debugMode) {
|
||||
std::cout << "Proxy Addresse: "<< ip << ":" << port << std::endl;
|
||||
}
|
||||
settings->proxy_ip = ip;
|
||||
settings->proxy_port = port;
|
||||
}
|
||||
break;
|
||||
case 'h':
|
||||
unterOption_info_help();
|
||||
return -1;
|
||||
case 'c':
|
||||
settings->colorless = true;
|
||||
if(settings->debugMode)
|
||||
std::cout << "Farblos: true" << std::endl;
|
||||
break;
|
||||
case 'd':
|
||||
settings->debugMode = true;
|
||||
if(settings->debugMode)
|
||||
std::cout << "Debug Modus: true" << std::endl;
|
||||
break;
|
||||
default:
|
||||
std::cout << "Aufruf: " << getProgramName() << " info [OPTION]... [NAME]..." << std::endl;
|
||||
std::cout << "„" << getProgramName() << " info --help“ liefert weitere Informationen." << std::endl;
|
||||
return 21;
|
||||
}
|
||||
}
|
||||
|
||||
//Alle nicht verwendeten Parameter == Name
|
||||
while (optind < argc) {
|
||||
if(argv[optind][0]) {
|
||||
settings->name.append(argv[optind++]).append(" ");
|
||||
} else
|
||||
optind++;
|
||||
}
|
||||
if(settings->name.length() > 0)
|
||||
settings->name.pop_back();
|
||||
if(settings->debugMode) {
|
||||
std::cout << "Name: " << settings->name << std::endl;
|
||||
std::cout << "Modus: Search_MODUS" << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void unterOption_info_help()
|
||||
{
|
||||
std::cout << "Usage: " << getProgramName() << " info [OPTION]... [NAME]..." << std::endl
|
||||
<< "Parameter:" << std::endl
|
||||
<< "\t-p [Socks5Proxy], --socks5-proxy [Socks5Proxy]" << std::endl
|
||||
<< "\t -> Verwende diesen Socks5-Proxy. Default: 127.0.0.1:9050" << std::endl
|
||||
<< "\t-c, --colorless" << std::endl
|
||||
<< "\t -> Gib keine Farbigen Infos aus. Default: false" << std::endl
|
||||
<< "\t-d, --debug-mode" << std::endl
|
||||
<< "\t -> Debug Nachrichten an. Default: false" << std::endl
|
||||
<< "\t-h, --help" << std::endl
|
||||
<< "\t -> Gibt dieses Helpmenü aus." << std::endl;
|
||||
}
|
||||
|
||||
|
||||
void unterOption_clean(Settings * settings, int argc, char **argv)
|
||||
{
|
||||
if(argc > 2)
|
||||
if(strncmp("--help", argv[2], strlen(argv[2])) == 0) {
|
||||
std::cout << "Aufruf: " << getProgramName() << " clean" << std::endl << std::endl;
|
||||
std::cout << "Mit dieser Function werden die Cookie-Files gelöscht." << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned count = 0;
|
||||
if(fileExists(settings->cookieFilePath)) {
|
||||
if(remove(settings->cookieFilePath.c_str()) != 0) {
|
||||
std::cout << " => Error: Das löschen von " << settings->cookieFilePath << " ist fehlgeschlagen: " << errno << std::endl;
|
||||
return;
|
||||
} else
|
||||
count++;
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < UINT_MAX && fileExists(settings->cookieFilePath + std::to_string(i)); i++) {
|
||||
if(remove( (settings->cookieFilePath + std::to_string(i)).c_str() ) != 0) {
|
||||
std::cout << " => Error: Das löschen von " << settings->cookieFilePath + std::to_string(i) << " ist fehlgeschlagen: " << errno << std::endl;
|
||||
return;
|
||||
} else {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
if(count == 0)
|
||||
std::cout << " => Nichts zu tun: Keine Cookies vorhanden." << std::endl;
|
||||
else
|
||||
std::cout << " => " << count << " Cookie-File(s) gelöscht." << std::endl;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int compare(std::string All_Options_with_komma_between, std::string input)
|
||||
{
|
||||
std::istringstream iStrStream( All_Options_with_komma_between + "\n");
|
||||
std::string line;
|
||||
int allFounds = 0;
|
||||
while (getline(iStrStream, line).good())
|
||||
if(strncmp(line.c_str(), input.c_str(), input.length()) == 0) {
|
||||
allFounds++;
|
||||
//std::cout << "Unteroption '" << input << "' stimmt mit '" << line << "' überein." << std::endl;
|
||||
}
|
||||
return allFounds;
|
||||
}
|
||||
|
||||
bool dirExists(std::string dir)
|
||||
{
|
||||
struct stat sb;
|
||||
return (stat(dir.c_str(), &sb) == 0 && S_ISDIR(sb.st_mode)) ? true : false;
|
||||
}
|
||||
|
||||
std::string getProgramName()
|
||||
{
|
||||
return getexepath().erase(0, ( getexepath().find_last_of("/\\") != std::string::npos ) ? getexepath().find_last_of("/\\") +1 : 0 );
|
||||
}
|
||||
|
||||
std::string getexepath()
|
||||
{
|
||||
#ifdef linux
|
||||
char result[ PATH_MAX ];
|
||||
ssize_t count = readlink( "/proc/self/exe", result, PATH_MAX );
|
||||
return std::string( result, (count > 0) ? static_cast<size_t>(count) : 0 );
|
||||
#endif
|
||||
#ifdef ABC ///_WIN32
|
||||
//wchar_t result[ MAX_PATH ];
|
||||
char buffer[MAX_PATH];
|
||||
return std::string( result, GetModuleFileName( NULL, buffer, MAX_PATH ) );
|
||||
//GetModuleFileName(NULL, result, MAX_PATH) ;
|
||||
//return reinterpret_cast<char*>(result);
|
||||
#endif
|
||||
}
|
||||
|
||||
void setPathSymbol(Settings &settings)
|
||||
{
|
||||
#ifdef linux
|
||||
settings.pathSymbol = '/';
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
settings.pathSymbol = '\\';
|
||||
#endif
|
||||
}
|
||||
|
||||
bool fileExists (const std::string& name) {
|
||||
struct stat buffer;
|
||||
return (stat (name.c_str(), &buffer) == 0 && S_ISREG(buffer.st_mode));
|
||||
}
|
||||
|
@ -1,92 +0,0 @@
|
||||
#ifndef PARAMETERMANAGER_H
|
||||
#define PARAMETERMANAGER_H
|
||||
|
||||
#include <iostream>
|
||||
#include <getopt.h>
|
||||
#include <string.h>
|
||||
#include <sstream>
|
||||
#include <sys/stat.h>
|
||||
#include <fstream>
|
||||
#include <limits.h> // PATH_MAX
|
||||
#include <unistd.h> // readlink()
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
enum Modus {
|
||||
EXIT = -1,
|
||||
DEFAULT_MODUS = 0,
|
||||
DIRECT_LINK_MODUS = 1,
|
||||
SEARCH_MODUS = 2,
|
||||
INFO_MODUS = 3
|
||||
|
||||
};
|
||||
|
||||
|
||||
struct Settings {
|
||||
Settings() {}
|
||||
Settings(std::string name) : name(name) {}
|
||||
|
||||
std::string name,
|
||||
accountFilePath = "/tmp/a",
|
||||
accountNumberPath= "/tmp/a_n",
|
||||
cookieFilePath = "/tmp/S_New4_cookies",
|
||||
serienListPath = "/tmp/SerienListe",
|
||||
defaultsFilePath = "/tmp/defaults",
|
||||
proxy_ip = "127.0.0.1",
|
||||
languages = "GerDub,GerSub,Eng",
|
||||
genaueHoster = "Vivo,GoUnlimited",
|
||||
version = "2.3.0",
|
||||
defaultFileVersion="1.3",
|
||||
outputFilePath = "",
|
||||
default_checkDirPath = "",
|
||||
default_Searchmuster = "S%Staffel%E%Folge%";
|
||||
|
||||
Modus modus = Modus::DEFAULT_MODUS;
|
||||
bool colorless = false,
|
||||
debugMode = false,
|
||||
search_IgnoreUpperLower = true,
|
||||
search_wantUpdate = false;
|
||||
int startEpisode = 1,
|
||||
stopEpisode = 0,
|
||||
startSeason = 1,
|
||||
stopSeason = 0,
|
||||
proxy_port = 9050,
|
||||
default_maxDirs = 20;
|
||||
char pathSymbol = '/';
|
||||
unsigned maxThreads = 0;
|
||||
|
||||
};
|
||||
|
||||
int manageParameter(Settings &settings, int argc, char ** argv);
|
||||
int loadDefaulOptions(Settings & settings);
|
||||
int compare(std::string All_Options_with_komma_between, std::string input);
|
||||
|
||||
std::string getProgramName();
|
||||
std::string getexepath();
|
||||
|
||||
void setPathSymbol(Settings &settings);
|
||||
void setPaths(Settings &settings);
|
||||
|
||||
bool fileExists (const std::string& name);
|
||||
bool dirExists(std::string dir);
|
||||
|
||||
int unterOption_help();
|
||||
|
||||
int unterOption_default(Settings * settings, int argc, char **argv);
|
||||
void unterOption_default_help();
|
||||
|
||||
int unterOption_url(Settings * settings, int argc, char **argv);
|
||||
void unterOption_url_help();
|
||||
|
||||
int unterOption_search(Settings * settings, int argc, char **argv);
|
||||
void unterOption_search_help();
|
||||
|
||||
int unterOption_info(Settings * settings, int argc, char **argv);
|
||||
void unterOption_info_help();
|
||||
|
||||
void unterOption_clean(Settings * settings, int argc, char **argv);
|
||||
|
||||
|
||||
#endif // PARAMETERMANAGER_H
|
@ -1,723 +0,0 @@
|
||||
#include "programManager.h"
|
||||
|
||||
|
||||
ProgramManager::ProgramManager()
|
||||
: nextThread(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
ProgramManager::~ProgramManager()
|
||||
{
|
||||
for(auto e : threadList) {
|
||||
delete e->pageManager;
|
||||
delete e;
|
||||
e = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
int ProgramManager::start(Settings *settings)
|
||||
{
|
||||
pageManager.setProxy(settings->proxy_ip, settings->proxy_port);
|
||||
pageManager.setDebugMode(settings->debugMode);
|
||||
pageManager.setCookieFilePath(settings->cookieFilePath);
|
||||
if(dirExists(settings->cookieFilePath)) {
|
||||
std::cout << " => Error: Kann Cokkie-File nicht erstellen: Es existiert bereits ein Ordner mit diesem Namen: \n '"
|
||||
<< settings->cookieFilePath << "'." << std::endl;
|
||||
return 174;
|
||||
}
|
||||
|
||||
switch (settings->modus) {
|
||||
case Modus::DEFAULT_MODUS:
|
||||
return defaultModus(settings);
|
||||
case Modus::DIRECT_LINK_MODUS:
|
||||
return directLinkModus(settings);
|
||||
case Modus::SEARCH_MODUS:
|
||||
return searchModus(settings);
|
||||
case Modus::INFO_MODUS:
|
||||
return infoModus(settings);
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
void * threadFunction(void * data) {
|
||||
ThreadData * myThreadData = reinterpret_cast<struct ThreadData*>(data);
|
||||
myThreadData->returnValue="";
|
||||
myThreadData->exitState=0;
|
||||
|
||||
|
||||
Reply tmp_reply = myThreadData->pageManager->getServerRequest(myThreadData->pageManager->UrlPraefix + myThreadData->nameInUrl
|
||||
+ "/staffel-" + std::to_string(myThreadData->staffel) + "/episode-" + std::to_string(myThreadData->folge));
|
||||
if(tmp_reply.html == "-1")
|
||||
return myThreadData->setState(10);
|
||||
std::string allLinks = myThreadData->pageManager->getLinks(tmp_reply.html);
|
||||
std::string Link = myThreadData->pageManager->chooseHosterLink(allLinks, myThreadData->settings->genaueHoster, myThreadData->settings->languages);
|
||||
|
||||
if(myThreadData->settings->debugMode)
|
||||
std::cout << " > Thread " << myThreadData->id << allLinks << std::endl << ( (Link == "") ? "" : " -> Link: 'https://s.to") << Link << ( (Link == "") ? "" : "'\n" );
|
||||
|
||||
|
||||
|
||||
|
||||
std::string folgenID = std::string((myThreadData->staffel == -1 || myThreadData->folge == -1 ) ? "" : "S" + std::string( (myThreadData->staffel < 10) ? "0" : "" ) + std::to_string(myThreadData->staffel)
|
||||
+ "E" + std::string( (myThreadData->folge < 10) ? "0" : "" ) + std::to_string( myThreadData->folge ) );
|
||||
std::string green = ((myThreadData->settings->colorless) ? "" : "\033[32m"),
|
||||
red = ((myThreadData->settings->colorless) ? "" : "\033[31m"),
|
||||
orange =((myThreadData->settings->colorless) ? "" : "\033[33m"),
|
||||
blue = ((myThreadData->settings->colorless) ? "" : "\033[34m");
|
||||
|
||||
if(Link == "") {
|
||||
if(allLinks == "") {
|
||||
myThreadData->returnValue = " => " + red + "KEINEN Hoster für die Folge " + folgenID + " gefunden." + "\033[0m";
|
||||
if(myThreadData->pageManager->writeToFile(myThreadData->settings->outputFilePath, std::string("KEINEN Hoster für die Folge ") + folgenID + std::string(" gefunden.")) != 0)
|
||||
return myThreadData->setState(14);
|
||||
}
|
||||
else {
|
||||
myThreadData->returnValue = " => " + orange + "Keinen PASSENDEN Hoster für die Folge " + folgenID + " gefunden." + "\033[0m" + "\n"
|
||||
+ "Alle Links:" + "\n"
|
||||
+ myThreadData->pageManager->replace( myThreadData->pageManager->replace( myThreadData->pageManager->replace( allLinks, "data-lang-key=\"1\"", "language=\"GerDub\"" ),
|
||||
"data-lang-key=\"2\"", "language=\"Eng\"" ), "data-lang-key=\"3\"", "language=\"GerSub\"");
|
||||
if(myThreadData->pageManager->writeToFile(myThreadData->settings->outputFilePath, std::string("Keinen PASSENDEN Hoster für die Folge ") + folgenID + std::string(" gefunden.")) != 0)
|
||||
return myThreadData->setState(15);
|
||||
}
|
||||
return myThreadData->setState(0);
|
||||
}
|
||||
|
||||
for (int i = 1; i <= 3; ++i) {
|
||||
std::string newUrl = myThreadData->pageManager->getUrlAfterRedirect("https://s.to" + Link);
|
||||
if (newUrl == "-1") {
|
||||
return myThreadData->setState(16);
|
||||
} else if(newUrl.find("/s.to/redirect/") != std::string::npos ) {
|
||||
if(myThreadData->settings->debugMode)
|
||||
std::cout << " > Thread " << myThreadData->id << "Warnung: Redirect Link nach umwandlung (Capcha?) --> Neuer Account" << std::endl;
|
||||
if(myThreadData->pageManager->login(myThreadData->accountManager->getNextAccount()) != 0)
|
||||
return myThreadData->setState(17);
|
||||
continue;
|
||||
|
||||
} else {
|
||||
myThreadData->returnValue = " => " + folgenID + ( (folgenID == "") ? "" : ": " ) + green + newUrl + "\033[0m";
|
||||
if(myThreadData->settings->outputFilePath != "")
|
||||
if(myThreadData->pageManager->writeToFile(myThreadData->settings->outputFilePath,folgenID + ( (folgenID == "") ? "" : ": " ) + newUrl) != 0)
|
||||
return myThreadData->setState(18);
|
||||
return myThreadData->setState(0);
|
||||
}
|
||||
}
|
||||
myThreadData->returnValue = " => " + folgenID + ( (folgenID == "") ? "" : ": " ) + red + "https://s.to" + Link + "\033[0m";
|
||||
if(myThreadData->settings->outputFilePath != "")
|
||||
if(myThreadData->pageManager->writeToFile(myThreadData->settings->outputFilePath, folgenID + ( (folgenID == "") ? "" : ": " ) + Link) != 0)
|
||||
return myThreadData->setState(19);
|
||||
return myThreadData->setState(0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
int ProgramManager::defaultModus(Settings *settings)
|
||||
{
|
||||
AccountManager accountManager(settings->accountFilePath, settings->accountNumberPath);
|
||||
|
||||
//Wenn kein Name mit -n Angegeben wurde:
|
||||
if(settings->name == "") {
|
||||
if(settings->default_checkDirPath != "") {
|
||||
if(settings->default_checkDirPath[settings->default_checkDirPath.length()-1] == settings->pathSymbol)
|
||||
settings->default_checkDirPath.pop_back();
|
||||
size_t pos = settings->default_checkDirPath.find_last_of(std::string(1, settings->pathSymbol));
|
||||
if( pos != std::string::npos) {
|
||||
settings->name = settings->default_checkDirPath.substr(pos + 1);
|
||||
if(settings->debugMode)
|
||||
std::cout << " > Use Path for Name: " << settings->default_checkDirPath << " -> " << settings->name << std::endl;
|
||||
}
|
||||
} if(settings->name == "") {
|
||||
std::cout << " => Error: Kein Name angegeben." << std::endl;
|
||||
std::cout << "Aufruf: " << getProgramName() << " default [OPTION]... [NAME]..." << std::endl;
|
||||
std::cout << "„" << getProgramName() << " default --help“ liefert weitere Informationen." << std::endl;
|
||||
return 27;
|
||||
}
|
||||
}
|
||||
|
||||
//Überprüfe ob ein Muster existiert:
|
||||
if(settings->default_checkDirPath != "" && settings->default_Searchmuster == "") {
|
||||
std::cout << " => Error: [-m]: Kein Muster angegeben." << std::endl;
|
||||
return 31;
|
||||
}
|
||||
|
||||
|
||||
//Liste alle Dateien in dem Ornder von -C auf und speichere diese
|
||||
std::string dirFiles;
|
||||
if(settings->default_checkDirPath != "")
|
||||
if(listDir(dirFiles, settings->default_checkDirPath, settings->default_maxDirs ) != 0)
|
||||
return 28;
|
||||
|
||||
//Entferne von der liste das \n am ende
|
||||
if(dirFiles.length() > 0)
|
||||
dirFiles.pop_back();
|
||||
|
||||
//Wenn Debug Mode, gib die Liste aus
|
||||
if(settings->debugMode && settings->default_checkDirPath != "")
|
||||
std::cout << " > [-C] Files:\n" << dirFiles << std::endl;
|
||||
|
||||
//Führe Function aus, die überprüft ob die serie existiert
|
||||
std::string nameInUrl =pageManager.checkName(settings->name);
|
||||
if(nameInUrl == "-1") {
|
||||
//Wenn nicht, dann fühe noch eine Suche nach ähnlichen durch.
|
||||
searchModus(settings);
|
||||
return 25;
|
||||
}
|
||||
|
||||
/* Wenn multihtreading seaktiviert ist, normal login sonst bereite threads vor
|
||||
if(settings->maxThreads == 0) {
|
||||
// melde bei s.to an und speicher cookies.
|
||||
if (pageManager.login(accountManager.getNextAccount()) != 0) //----------------------------------------
|
||||
return 29;
|
||||
}*/
|
||||
|
||||
if(settings->maxThreads > 0) {
|
||||
for (unsigned i = 0; i < settings->maxThreads; ++i) {
|
||||
if(dirExists(settings->cookieFilePath + std::to_string( i ))) {
|
||||
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;
|
||||
return 174;
|
||||
}
|
||||
PageManager * pm = new PageManager("socks5://" + settings->proxy_ip + ":" + std::to_string(settings->proxy_port), settings->cookieFilePath + std::to_string( i ));
|
||||
pm->setDebugMode(settings->debugMode);
|
||||
|
||||
//pm->setProxy(settings->proxy_ip, settings->proxy_port);
|
||||
//pm->setCookieFilePath(settings->cookieFilePath + std::to_string( i ));
|
||||
|
||||
ThreadData * newThreadData = new ThreadData(i, 0, nameInUrl, -1, settings, &accountManager, pm);
|
||||
threadList.push_back(newThreadData);
|
||||
}
|
||||
}
|
||||
|
||||
//Write Name to File if -o is set
|
||||
pageManager.writeToFile(settings->outputFilePath, "Name: " + settings->name);
|
||||
|
||||
//Finde die anzahl der staffel heraus:
|
||||
//download html von der startpage einer serie
|
||||
Reply tmp_reply = pageManager.getServerRequest(pageManager.UrlPraefix + nameInUrl);
|
||||
if(tmp_reply.html == "-1")
|
||||
return 32;
|
||||
//speicher zahl -1, ab da wo /staffel-x nicht mehr vorkommt
|
||||
int maxStaffel = pageManager.counterContains(tmp_reply.html, "/staffel-%i");
|
||||
|
||||
if(settings->debugMode)
|
||||
std::cout << " > Die Serie " << settings->name << " hat " << maxStaffel << " Staffeln." << std::endl;
|
||||
|
||||
//For every season
|
||||
for (int staffel = settings->startSeason; staffel <= maxStaffel; ++staffel) {
|
||||
|
||||
//Find out number of all episodes
|
||||
tmp_reply = pageManager.getServerRequest(pageManager.UrlPraefix + nameInUrl + "/staffel-" + std::to_string(staffel));
|
||||
if(tmp_reply.html == "-1")
|
||||
return 40;
|
||||
int maxFolge = pageManager.counterContains(tmp_reply.html, "/episode-%i");
|
||||
|
||||
if(settings->debugMode)
|
||||
std::cout << " > Die Staffel " << staffel << " hat " << maxFolge << " Folgen." << std::endl;
|
||||
|
||||
//for every episode
|
||||
for (int folge = settings->startEpisode; folge <= maxFolge; ++folge) {
|
||||
|
||||
//Überprüfe ob, wenn -C vorhanden, die Folge in dem Ordner bereits vorkommt.
|
||||
if(settings->default_checkDirPath != "") {
|
||||
if(dirFiles.find(pageManager.replace( pageManager.replace( settings->default_Searchmuster, "%Staffel%", ((staffel < 10) ? "0" : "") + std::to_string(staffel) ),
|
||||
"%Folge%", ((folge < 10) ? "0" : "") + std::to_string(folge) ) ) != std::string::npos) {
|
||||
if(settings->debugMode)
|
||||
std::cout << " > Skippe Folge: S" << staffel << "E" << folge << std::endl;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
//Multihreading Mode
|
||||
if(settings->maxThreads > 0) {
|
||||
//Wenn nex Thread noch in den Vector passt(weniger Threads als Max), dann Starte neuen mit data aus dem Vector...
|
||||
if(nextThread < threadList.size()) {
|
||||
threadList[nextThread]->exitState = 0;
|
||||
threadList[nextThread]->setData(staffel, folge);
|
||||
if(pthread_create(&threadList[nextThread]->thread, nullptr, threadFunction, reinterpret_cast<void*>(threadList[nextThread])) != 0 ) {
|
||||
perror("pthread_creat failed");
|
||||
return 48;
|
||||
}
|
||||
nextThread++;
|
||||
} else { // Sonnst warte bis alle Fertig sind und restarte die Folge
|
||||
if(waitForThreads() != 0)
|
||||
return 231;
|
||||
nextThread=0;
|
||||
folge--;
|
||||
continue;
|
||||
}
|
||||
|
||||
} else { // Default Mode
|
||||
tmp_reply =pageManager.getServerRequest(pageManager.UrlPraefix + nameInUrl + "/staffel-" + std::to_string(staffel) + "/episode-" + std::to_string(folge));
|
||||
if(tmp_reply.html == "-1")
|
||||
return 50;
|
||||
std::string allLinks = pageManager.getLinks(tmp_reply.html);
|
||||
std::string Link = pageManager.chooseHosterLink(allLinks, settings->genaueHoster, settings->languages);
|
||||
|
||||
if(settings->debugMode)
|
||||
std::cout << allLinks << std::endl << ( (Link == "") ? "" : " -> Link: 'https://s.to") << Link << ( (Link == "") ? "" : "'\n" );
|
||||
if(convertLink(Link, &accountManager, settings, staffel, folge, allLinks) != 0)
|
||||
return 51;
|
||||
|
||||
}
|
||||
|
||||
if(folge == settings->stopEpisode && settings->stopSeason < 1) { // stoppe wenn stopfolge gleich der folge ist und stopstaffel nicht gesetzt wurde.
|
||||
if(settings->maxThreads != 0)
|
||||
if(waitForThreads() != 0)
|
||||
return 261;
|
||||
return 0;
|
||||
|
||||
} else if ( folge == settings->stopEpisode && staffel == settings->stopSeason) { // stoppe wenn stopfolge = folge && stopstaffel == staffel
|
||||
if(settings->maxThreads != 0)
|
||||
if(waitForThreads() != 0)
|
||||
return 267;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
//Setzte Startepisode zurück für nächste Staffel
|
||||
settings->startEpisode = 1;
|
||||
|
||||
if(staffel == settings->stopSeason) {
|
||||
if(settings->debugMode)
|
||||
std::cout << " > Stoppe, weil Staffel: " << staffel << " == StopStaffel " << settings->stopSeason << std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(settings->maxThreads != 0)
|
||||
if(waitForThreads() != 0)
|
||||
return 292;
|
||||
|
||||
std::cout << " > Fertig" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ProgramManager::waitForThreads()
|
||||
{
|
||||
for( auto &e : threadList) {
|
||||
if( e->exitState != -1 && pthread_join(e->thread, nullptr) == 0) {
|
||||
if(e->exitState != 0) {
|
||||
std::cout << "\33[2K\r => Error: Thread gab error zurück." << std::endl;
|
||||
return e->exitState;
|
||||
} else
|
||||
if(e->returnValue != "")
|
||||
std::cout << ("\33[2K\r(T" + std::to_string(e->id) + ")" + e->returnValue ) << std::endl;
|
||||
}
|
||||
e->exitState = -1;
|
||||
e->returnValue = "";
|
||||
e->setData(0, 0);
|
||||
e->thread = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int ProgramManager::directLinkModus(Settings *settings)
|
||||
{
|
||||
AccountManager accountManager(settings->accountFilePath, settings->accountNumberPath);
|
||||
|
||||
if(settings->name == "") {
|
||||
std::cout << " => Error: Kein(e) Link(s) angegeben." << std::endl;
|
||||
std::cout << "Aufruf: " << getProgramName() << " url [OPTION]... [URL]..." << std::endl;
|
||||
std::cout << "„" << getProgramName() << " url --help“ liefert weitere Informationen." << std::endl;
|
||||
return 76;
|
||||
}
|
||||
|
||||
std::istringstream iStrStream( pageManager.replace( settings->name, ",", "\n" ) + "\n" );
|
||||
std::string line;
|
||||
|
||||
//if(pageManager.login(accountManager.getNextAccount()) != 0)
|
||||
// return 71;
|
||||
|
||||
while (getline(iStrStream, line).good()) {
|
||||
if(line.find("https://s.to/redirect/") == std::string::npos) {
|
||||
std::cout << " => Error: Invalid Redirect Link: '" << line << "'" << std::endl;
|
||||
continue;
|
||||
}
|
||||
else if(convertLink(pageManager.replace(line, "https://s.to", ""), &accountManager, settings) != 0)
|
||||
return 78;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ProgramManager::searchModus(Settings *settings)
|
||||
{
|
||||
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;
|
||||
else
|
||||
std::cout << "Error: Das updaten der Serienliste ist fehlgeschlagen." << std::endl;
|
||||
return res;
|
||||
|
||||
} else if(settings->name == "") {
|
||||
std::cout << " => Error: Kein Name angegeben." << std::endl;
|
||||
std::cout << "Aufruf: " << getProgramName() << " search [OPTION]... [NAME]..." << std::endl;
|
||||
std::cout << "„" << getProgramName() << " search --help“ liefert weitere Informationen." << std::endl;
|
||||
return 27;
|
||||
}
|
||||
|
||||
std::ifstream ifs(settings->serienListPath);
|
||||
if(!ifs.is_open()) {
|
||||
std::cout << "Keine SerienListe vorhanden. Erstelle eine neue..." << std::endl;
|
||||
if(searchModus_update(settings) != 0)
|
||||
return 354;
|
||||
else {
|
||||
ifs.open(settings->serienListPath);
|
||||
if(!ifs.is_open()) {
|
||||
perror(" => Error: Couldn't open SerienList file after update again.");
|
||||
return 434;
|
||||
}
|
||||
std::cout << "Erfolgreich gedownloadet." << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
//Save file in string:
|
||||
std::string serienListe((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>());
|
||||
|
||||
//Suche alle Möglichkeiten
|
||||
std::string finds = pageManager.grep(serienListe, settings->name, settings->search_IgnoreUpperLower);
|
||||
serienListe.clear(); // Speicher freigeben
|
||||
|
||||
/*//Text mit Farben versehen
|
||||
if(!settings->colorless) {
|
||||
for (size_t pos = pageManager.upper_string( finds ).find( pageManager.upper_string( settings->name ), 0);
|
||||
pos != std::string::npos;
|
||||
pos = pageManager.upper_string( finds ).find( pageManager.upper_string( settings->name ), pos + settings->name.length() + strlen("\033[37m\033[0m")))
|
||||
finds.insert(pos, ( (finds.find(settings->name, pos) == pos) ? "\033[32m" : "\033[36m" ) ).insert(pos + settings->name.length() + strlen("\033[37m"), "\033[0m");
|
||||
}*/
|
||||
|
||||
//Text mit Farben versehen
|
||||
if(!settings->colorless) {
|
||||
std::string UpperFinds = pageManager.upper_string( finds );
|
||||
std::string UpperName = pageManager.upper_string( settings->name );
|
||||
for (size_t pos = UpperFinds.find( UpperName, 0); pos != std::string::npos; pos = UpperFinds.find( UpperName, pos + settings->name.length() + strlen("\033[37m\033[0m"))) {
|
||||
bool exaktGeschrieben = (finds.find(settings->name, pos) == pos);
|
||||
finds.insert(pos, ( (exaktGeschrieben) ? "\033[32m" : "\033[36m" ) ).insert(pos + settings->name.length() + strlen("\033[37m"), "\033[0m");
|
||||
UpperFinds.insert(pos, ( (exaktGeschrieben ) ? "\033[32m" : "\033[36m" ) ).insert(pos + settings->name.length() + strlen("\033[37m"), "\033[0m");
|
||||
}
|
||||
}
|
||||
//Ausgabe
|
||||
if(finds == "") {
|
||||
std::cout << " => Für '" << settings->name << "' wurde(n) keine Serie(n) gefunden." << std::endl;
|
||||
return 0;
|
||||
}
|
||||
std::stringstream strstream(finds);
|
||||
std::string line;
|
||||
std::cout << " => Für '" << settings->name << "' wurde(n) folgende Serie(n) gefunden: " << std::endl;
|
||||
while (getline(strstream, line)) {
|
||||
std::cout << " > " << line.substr(line.find("|", line.find("/")) + 1, line.length() - line.find("|", line.find("/")) -1 )
|
||||
<< "\t[" << line.substr(line.find("/") + 1, line.find("|", line.find("/")) - line.find("/") - 1) << "]"
|
||||
<< ( (line[0] == '|') ? "" : "\t( " + line.substr(0, line.find("|")) + " )" ) << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ProgramManager::infoModus(Settings *settings)
|
||||
{
|
||||
if(settings->name == "") {
|
||||
std::cout << " => Error: Kein Name angegeben." << std::endl;
|
||||
std::cout << "Aufruf: " << getProgramName() << " info [OPTION]... [NAME]..." << std::endl;
|
||||
std::cout << "„" << getProgramName() << " info --help“ liefert weitere Informationen." << std::endl;
|
||||
return 27;
|
||||
}
|
||||
|
||||
//Führe Function aus, die überprüft ob die serie existiert
|
||||
std::string nameInUrl = pageManager.checkName(settings->name);
|
||||
if(nameInUrl == "-1") {
|
||||
//Wenn nicht, dann fühe noch eine Suche nach ähnlichen durch.
|
||||
searchModus(settings);
|
||||
return 25;
|
||||
}
|
||||
|
||||
//Finde Anzahl der Staffel heraus:
|
||||
Reply tmp_reply = pageManager.getServerRequest(pageManager.UrlPraefix + nameInUrl);
|
||||
if(tmp_reply.html == "-1")
|
||||
return 32;
|
||||
|
||||
//speicher (zahl -1), ab da wo /staffel-x nicht mehr vorkommt
|
||||
int maxStaffel = pageManager.counterContains(tmp_reply.html, "/staffel-%i");
|
||||
|
||||
//Um namen der Folge für jede Staffel zu bekommen
|
||||
for (int staffel = 1; staffel <= maxStaffel; ++staffel) {
|
||||
Reply tmpReply = pageManager.getServerRequest(pageManager.UrlPraefix + nameInUrl + "/staffel-" + std::to_string(staffel));
|
||||
if(tmpReply.html == "-1")
|
||||
return 40;
|
||||
std::cout << " > Die Staffel " << staffel << " hat " << pageManager.counterContains(tmp_reply.html, "/episode-%i") << " Folge(n)." << std::endl;
|
||||
|
||||
}
|
||||
|
||||
//Datum & FSK
|
||||
std::string line = pageManager.grep(tmp_reply.html, "<small> (<span itemprop=\"startDate\"><a");
|
||||
if(line == "") {
|
||||
std::cout << " => Error: Konnte '<small> (<span itemprop=\"startDate\"><a' nicht finden." << std::endl;
|
||||
return 83;
|
||||
}
|
||||
|
||||
std::string startStopDates[2];
|
||||
size_t pos = 0, pos2 = 0;
|
||||
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
if( (pos = line.find("href=")) == std::string::npos ) {
|
||||
std::cout << " => Error: Konnte 'href=' nicht finden." << std::endl;
|
||||
return 84;
|
||||
} else
|
||||
line.erase(0, pos + 5);
|
||||
|
||||
if( (pos = line.find(">")) == std::string::npos ) {
|
||||
std::cout << " => Error: Konnte '>' nicht finden." << std::endl;
|
||||
return 85;
|
||||
} else if ((pos2 = line.find("</a>")) == std::string::npos ) {
|
||||
std::cout << " => Error: Konnte '</a>' nicht finden." << std::endl;
|
||||
return 86;
|
||||
}
|
||||
startStopDates[i] = line.substr(pos + 1, pos2 - pos -1);
|
||||
}
|
||||
|
||||
if( (pos = line.find("data-fsk=\"")) == std::string::npos ) {
|
||||
std::cout << " => Error: Konnte 'data-fsk=\"' nicht finden." << std::endl;
|
||||
return 87;
|
||||
} else if ((pos2 = line.find("\" class=\"fsk")) == std::string::npos ) {
|
||||
std::cout << " => Error: Konnte '\" class=\"fsk' nicht finden." << std::endl;
|
||||
return 86;
|
||||
}
|
||||
std::string fsk = line.substr(pos + 10, pos2 -pos - 10);
|
||||
|
||||
//Deskription
|
||||
if( (pos = tmp_reply.html.find("data-full-description=")) == std::string::npos) {
|
||||
std::cout << " => Error: Konnte 'data-full-description=' nicht finden." << std::endl;
|
||||
return 83;
|
||||
} else if ((pos2 = tmp_reply.html.find("\">", pos)) == std::string::npos ) {
|
||||
std::cout << " => Error: Konnte '\">' nicht finden." << std::endl;
|
||||
return 86;
|
||||
}
|
||||
std::string description = pageManager.replace( pageManager.replace( tmp_reply.html.substr(pos + 23, pos2 - pos - 23), "\n", "" ), "<br />", "" );
|
||||
|
||||
//Genres
|
||||
std::vector<std::string> genres;
|
||||
line = pageManager.grep(tmp_reply.html, "\"genre\">");
|
||||
if(line == "") {
|
||||
std::cout << " => Error: Konnte '\"genre\">' nicht finden." << std::endl;
|
||||
return 87;
|
||||
}
|
||||
for (pos = line.find("\"genre\">"); pos != std::string::npos; pos = line.find("\"genre\">", pos + 7)) {
|
||||
if( (pos2 = line.find("</a>", pos)) == std::string::npos) {
|
||||
std::cout << " => Error: Konnte '</a>' nicht finden." << std::endl;
|
||||
return 89;
|
||||
}
|
||||
genres.push_back(line.substr(pos + 8, pos2 - pos - 8));
|
||||
}
|
||||
|
||||
//CoverLink
|
||||
line = pageManager.grep(tmp_reply.html, "title=\"Cover");
|
||||
if( (pos = line.find("data-src=\"")) == std::string::npos) {
|
||||
std::cout << " => Error: Konnte 'data-src=\"' nicht finden." << std::endl;
|
||||
return 90;
|
||||
} else if ((pos2 = line.find("\"", pos + 10)) == std::string::npos ) {
|
||||
std::cout << " => Error: Konnte '\"' nicht finden." << std::endl;
|
||||
return 86;
|
||||
}
|
||||
std::string coverLink = line.substr(pos + 10, pos2 - pos -10);
|
||||
|
||||
|
||||
|
||||
|
||||
std::cout << "Produktion von " << startStopDates[0] << " bis " << startStopDates[1] << std::endl
|
||||
<< "FSK: " << fsk << std::endl
|
||||
<< "Cover Bild: " << coverLink << std::endl
|
||||
<< "Genre(s): " << std::flush;
|
||||
for( const auto &e : genres)
|
||||
std::cout << e << " ";
|
||||
|
||||
std::cout << std::endl << "\nBeschreibung: " << description << std::endl;
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ProgramManager::searchModus_update(Settings *settings)
|
||||
{
|
||||
Reply reply = pageManager.getServerRequest("https://s.to/serien");
|
||||
if(reply.html == "-1")
|
||||
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 = pageManager.replace( pageManager.grep( reply.html, "data-alternative-title" ), "</li>", "\n" );
|
||||
|
||||
if(reply.html.find("\" href=\"") == std::string::npos ||
|
||||
reply.html.find("<li><a data-alternative-title=\"") == std::string::npos ||
|
||||
reply.html.find("/serie/stream/") == std::string::npos ||
|
||||
reply.html.find("</a>") == std::string::npos)
|
||||
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 = pageManager.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 = pageManager.replace(serienListe, "\" href=\"", "|");
|
||||
//...\n|/serie/stream/2012-das-jahr-null" title="2012 - Das Jahr Null Stream anschauen">2012 - Das Jahr Null</a>\n...
|
||||
serienListe = pageManager.replace(serienListe, "|/serie/stream/", "|/");
|
||||
|
||||
std::stringstream strstream(serienListe);
|
||||
std::string line;
|
||||
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 = pageManager.replace(line, "\">", "|");
|
||||
//...\n|/serie/stream/2012-das-jahr-null|2012 - Das Jahr Null</a>\n...
|
||||
line = pageManager.replace(line, "</a>", "");
|
||||
//...\n|/serie/stream/2012-das-jahr-null"_weg_>2012 - Das Jahr Null|\n...
|
||||
|
||||
serienListe += line + "\n";
|
||||
}
|
||||
if(serienListe.length() > 0)
|
||||
serienListe.pop_back();
|
||||
|
||||
//Anzahl der Serien/Zeilen vorher:
|
||||
ssize_t countBef = 0;
|
||||
std::ifstream myFileBef(settings->serienListPath);
|
||||
if(myFileBef.is_open())
|
||||
for(countBef = 0; std::getline(myFileBef,line); countBef++);
|
||||
myFileBef.close();
|
||||
|
||||
//Schreibe die Liste in das TextFile
|
||||
std::ofstream ofs(settings->serienListPath, std::ios::trunc);
|
||||
if(!ofs.is_open()) {
|
||||
perror("Konnte SerienListe-Datei nicht öffnen");
|
||||
return 111;
|
||||
}
|
||||
ofs << serienListe << std::endl;
|
||||
ofs.close();
|
||||
|
||||
//Anzahl der Zeile nachher
|
||||
ssize_t countAf = 0;
|
||||
std::ifstream myFileAf(settings->serienListPath);
|
||||
if(myFileAf.is_open())
|
||||
for(countAf = 0; std::getline(myFileAf,line); countAf++);
|
||||
myFileAf.close();
|
||||
|
||||
std::cout << "Serienunterschied: " << ( ((countAf - countBef) > 0) ? "+" : "") << countAf - countBef << " Serien." << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ProgramManager::listDir(std::string &list,std::string path, int maxDepth)
|
||||
{
|
||||
if(maxDepth <= 0)
|
||||
return 0;
|
||||
else if(!dirExists(path)) {
|
||||
std::cout << " => Error: Verzeichnis '" << path << "' existiert nicht oder ist kein Ordner." << std::endl;
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
maxDepth--;
|
||||
|
||||
if(path[path.length()-1] != '/')
|
||||
path.push_back('/');
|
||||
|
||||
DIR* dirp = opendir(path.c_str());
|
||||
if(!dirp) {
|
||||
perror(std::string(" => Error: Konnte Verzeichnis nicht öffnen: " + path).c_str());
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct dirent * dp;
|
||||
while ((dp = readdir(dirp)) != nullptr) {
|
||||
if(strcmp( dp->d_name, "." ) == 0 || strcmp ( dp->d_name, ".." ) == 0)
|
||||
continue;
|
||||
|
||||
else if(dirExists((path + dp->d_name + "/"))) { //if(dp->d_type == DT_DIR) {
|
||||
listDir(list, (path + dp->d_name + "/"), maxDepth);
|
||||
} else
|
||||
list.append( std::string(dp->d_name) + "\n" );
|
||||
}
|
||||
closedir(dirp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ProgramManager::convertLink(std::string redirectLink, AccountManager * accountManager,
|
||||
Settings * settings, int Staffel, int Folge, std::string allLinks)
|
||||
{
|
||||
std::string folgenID = std::string((Staffel == -1 || Folge == -1 ) ? "" : "S" + std::string( (Staffel < 10) ? "0" : "" ) + std::to_string(Staffel)
|
||||
+ "E" + std::string( (Folge < 10) ? "0" : "" ) + std::to_string( Folge ) );
|
||||
std::string green = ((settings->colorless) ? "" : "\033[32m"),
|
||||
red = ((settings->colorless) ? "" : "\033[31m"),
|
||||
orange =((settings->colorless) ? "" : "\033[33m"),
|
||||
blue = ((settings->colorless) ? "" : "\033[34m");
|
||||
|
||||
if(redirectLink == "" && settings->modus == Modus::DEFAULT_MODUS) {
|
||||
if(allLinks == "") {
|
||||
std::cout << " => " << red << "KEINEN Hoster für die Folge " << folgenID << " gefunden." << "\033[0m" << std::endl;
|
||||
if(pageManager.writeToFile(settings->outputFilePath, std::string("KEINEN Hoster für die Folge ") + folgenID + std::string(" gefunden.")) != 0)
|
||||
return 130;
|
||||
}
|
||||
else {
|
||||
std::cout << " => " << orange << "Keinen PASSENDEN Hoster für die Folge " << folgenID << " gefunden." << "\033[0m" << std::endl
|
||||
<< "Alle Links:" << std::endl
|
||||
<< pageManager.replace( pageManager.replace( pageManager.replace( allLinks, "data-lang-key=\"1\"", "language=\"GerDub\"" ),
|
||||
"data-lang-key=\"2\"", "language=\"Eng\"" ), "data-lang-key=\"3\"", "language=\"GerSub\"") << std::endl;
|
||||
if(pageManager.writeToFile(settings->outputFilePath, std::string("Keinen PASSENDEN Hoster für die Folge ") + folgenID + std::string(" gefunden.")) != 0)
|
||||
return 138;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (int i = 1; i <= 3; ++i) {
|
||||
std::string newUrl = pageManager.getUrlAfterRedirect("https://s.to" + redirectLink);
|
||||
if (newUrl == "-1") {
|
||||
return 102;
|
||||
} else if(newUrl.find("/s.to/redirect/") != std::string::npos ) {
|
||||
if(settings->debugMode)
|
||||
std::cout << "Warnung: Redirect Link nach umwandlung (Capcha?) --> Neuer Account" << std::endl;
|
||||
if(pageManager.login(accountManager->getNextAccount()) != 0)
|
||||
return -1;
|
||||
continue;
|
||||
|
||||
} else {
|
||||
std::cout << " => " << folgenID << ( (folgenID == "") ? "" : ": " ) << green << newUrl << "\033[0m" << std::endl;
|
||||
if(settings->outputFilePath != "")
|
||||
if(pageManager.writeToFile(settings->outputFilePath,folgenID + ( (folgenID == "") ? "" : ": " ) + newUrl) != 0)
|
||||
return 108;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
std::cout << " => " << folgenID << ( (folgenID == "") ? "" : ": " ) << red << "https://s.to" << redirectLink << "\033[0m" << std::endl;
|
||||
if(settings->outputFilePath != "")
|
||||
if(pageManager.writeToFile(settings->outputFilePath, folgenID + ( (folgenID == "") ? "" : ": " ) + redirectLink) != 0)
|
||||
return 114;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,61 +0,0 @@
|
||||
#ifndef MANAGEPROGRAM_H
|
||||
#define MANAGEPROGRAM_H
|
||||
|
||||
#include "pageManager.h"
|
||||
#include "parameterManager.h"
|
||||
#include "accountManager.h"
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <dirent.h>
|
||||
#include <pthread.h>
|
||||
|
||||
|
||||
struct ThreadData
|
||||
{
|
||||
ThreadData(unsigned id, pthread_t init, std::string nameinUrl,int exitStateInit, Settings * settings, AccountManager * accountMg, PageManager * pM)
|
||||
: id(id), thread(init), nameInUrl(nameinUrl), exitState(exitStateInit), settings(settings), accountManager(accountMg), pageManager(pM) {}
|
||||
|
||||
unsigned id;
|
||||
pthread_t thread;
|
||||
std::string nameInUrl, returnValue;
|
||||
int staffel, folge, exitState;
|
||||
Settings * settings;
|
||||
AccountManager * accountManager;
|
||||
PageManager * pageManager;
|
||||
|
||||
void * setState(int state) {
|
||||
this->exitState = state;
|
||||
return nullptr;
|
||||
}
|
||||
void setData(int staffel, int folge) { this->staffel = staffel; this->folge = folge; }
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
class ProgramManager
|
||||
{
|
||||
public:
|
||||
ProgramManager();
|
||||
~ProgramManager();
|
||||
int start(Settings *setting);
|
||||
int listDir(std::string &list, std::string path, int maxDepth);
|
||||
|
||||
private:
|
||||
int defaultModus(Settings * settings);
|
||||
int directLinkModus(Settings * settings);
|
||||
int searchModus(Settings * settings);
|
||||
int infoModus(Settings * settings);
|
||||
|
||||
PageManager pageManager;
|
||||
std::vector<ThreadData*> threadList;
|
||||
unsigned nextThread;
|
||||
|
||||
int convertLink(std::string redirectLink, AccountManager *accountManager, Settings * settings, int Staffel = -1, int Folge = -1, std::string allLinks = "NOT_EMPTY");
|
||||
int searchModus_update(Settings * settings);
|
||||
int waitForThreads();
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // MANAGEPROGRAM_H
|
Loading…
Reference in New Issue
Block a user