forked from markus/S_New4
v 1.0.1
This commit is contained in:
parent
278d59163a
commit
0cbdbb1812
@ -1,6 +1,7 @@
|
||||
QT -= gui
|
||||
LIBS += -lcurl
|
||||
|
||||
LIBS += -lcurl
|
||||
#LIBS += -LC:\Users\Markus\Desktop\S_New4\S_New4\curl -lcurl
|
||||
|
||||
CONFIG += c++11 console
|
||||
CONFIG -= app_bundle
|
||||
|
@ -1,16 +1,24 @@
|
||||
#include "accountManager.h"
|
||||
|
||||
AccountManager::AccountManager(std::string pathToFile)
|
||||
: lastReturnedAccount(0)
|
||||
AccountManager::AccountManager(std::string pathToFile, std::string pathToAccountNumberFile)
|
||||
: pathToAccountNumberFile(pathToAccountNumberFile)
|
||||
{
|
||||
std::ifstream ifs(pathToFile);
|
||||
if(!ifs.is_open()) {
|
||||
perror("Konnte Accounts Datei nicht öffnen");
|
||||
exit(12);
|
||||
if(writeDefault(pathToFile) != 0)
|
||||
exit(12);
|
||||
ifs.open(pathToFile);
|
||||
if(!ifs.is_open()) {
|
||||
std::cout << "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("/");
|
||||
|
||||
@ -27,14 +35,90 @@ AccountManager::AccountManager(std::string pathToFile)
|
||||
accounts.push_back(account);
|
||||
}
|
||||
|
||||
ifs.close();
|
||||
|
||||
}
|
||||
|
||||
Account AccountManager::getNextAccount()
|
||||
{
|
||||
lastReturnedAccount++;
|
||||
if( lastReturnedAccount >= accounts.size() )
|
||||
lastReturnedAccount=0;
|
||||
return accounts.at(lastReturnedAccount);
|
||||
if(accounts.size() == 0) {
|
||||
std::cout << "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("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 << "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 << "ErhellendSeltenerSeeloewe@ultra.fyi" << std::endl;
|
||||
ofs << "BefluegeltPrallerSchwan@spam.care" << std::endl;
|
||||
ofs << "FreundlichZuverlaessigerSchwan@spam.care" << std::endl;
|
||||
ofs << "HervorragendWundervollerReiher@oida.icu" << std::endl;
|
||||
ofs << "AnspruchsvollStilvollerUhu@magspam.net" << 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("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 << "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)
|
||||
|
@ -14,15 +14,19 @@ struct Account {
|
||||
class AccountManager
|
||||
{
|
||||
public:
|
||||
AccountManager(std::string pathToFile);
|
||||
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;
|
||||
size_t lastReturnedAccount;
|
||||
std::string pathToAccountNumberFile;
|
||||
};
|
||||
|
||||
#endif // ACCOUNTMANAGER_H
|
||||
|
@ -8,7 +8,7 @@ PageManager::PageManager(std::string sock5Proxy, std::string cookieFilePath)
|
||||
|
||||
PageManager::~PageManager()
|
||||
{
|
||||
///remove(cookieFilePath.c_str());
|
||||
remove(cookieFilePath.c_str());
|
||||
}
|
||||
|
||||
void PageManager::setProxy(std::string ip, std::string port)
|
||||
@ -16,6 +16,16 @@ void PageManager::setProxy(std::string ip, std::string port)
|
||||
this->sock5Proxy = "socks5://" + ip + ":" + 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
|
||||
@ -54,15 +64,26 @@ Reply PageManager::getServerRequest(std::string Url, bool useCookies, std::strin
|
||||
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::cout.flush();
|
||||
|
||||
/* Perform the request, res will get the return code */
|
||||
res = curl_easy_perform(curl);
|
||||
std::cout << "\33[2K\r";
|
||||
std::cout.flush();
|
||||
if(res != CURLE_OK) {
|
||||
if(timeout == maxTimeout) {
|
||||
perror((std::string("Error: curl_easy_perform() failed: ") + curl_easy_strerror(res)).c_str());
|
||||
return Reply("-1");
|
||||
} else {
|
||||
std::cout << "\33[2K\r" << "Warning: Versuch " << timeout << " von " << maxTimeout << ": curl_easy_perform() failed: " << curl_easy_strerror(res);
|
||||
std::cout.flush();
|
||||
sleep(1);
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
||||
if(res != CURLE_OK) {
|
||||
perror((std::string("Error: curl_easy_perform() failed: ") + curl_easy_strerror(res)).c_str());
|
||||
return Reply("-1");
|
||||
}
|
||||
|
||||
//Get Url
|
||||
@ -82,6 +103,9 @@ Reply PageManager::getServerRequest(std::string Url, bool useCookies, std::strin
|
||||
|
||||
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;
|
||||
@ -283,6 +307,10 @@ std::string PageManager::chooseHosterLink(std::string HosterList, std::string Ho
|
||||
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
|
||||
@ -290,14 +318,12 @@ std::string PageManager::chooseHosterLink(std::string HosterList, std::string Ho
|
||||
//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=\"' nicht finden." << std::endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
Line.erase(0, pos + static_cast<int>(strlen("href=\"")));
|
||||
|
||||
pos = Line.find("\"");
|
||||
@ -307,8 +333,6 @@ std::string PageManager::chooseHosterLink(std::string HosterList, std::string Ho
|
||||
}
|
||||
|
||||
return Line.erase(pos, Line.length()-pos);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,10 +2,11 @@
|
||||
#define MANAGEPAGE_H
|
||||
|
||||
#include <iostream>
|
||||
// if complied for windows; everything is in */projectfolder/curl/
|
||||
#include <curl/curl.h>
|
||||
#include <string.h>
|
||||
//#include <../../../../../home/markus/Downloads/Curl/include/curl/curl.h>
|
||||
#include <sstream>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "accountManager.h"
|
||||
|
||||
@ -25,7 +26,8 @@ public:
|
||||
~PageManager();
|
||||
|
||||
void setProxy(std::string ip, std::string 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);
|
||||
@ -42,6 +44,7 @@ public:
|
||||
const std::string UrlPraefix = "https://s.to/serie/stream/";
|
||||
private:
|
||||
std::string sock5Proxy, cookieFilePath;
|
||||
bool debugMode = false;
|
||||
};
|
||||
|
||||
#endif // MANAGEPAGE_H
|
||||
|
@ -4,558 +4,72 @@ Settings manageParameter(int argc, char **argv)
|
||||
{
|
||||
Settings settings;
|
||||
|
||||
std::string argv0 = argv[0];
|
||||
|
||||
argv0.erase(argv0.find_last_of("/\\") + 1 , argv0.length() - ( argv0.find_last_of("/\\") + 1) );
|
||||
|
||||
settings.cookieFilePath = argv0 + "S_New4_cookies";
|
||||
settings.accountFilePath = argv0 + "Accounts";
|
||||
settings.accountNumberPath = argv0 + "Account_Number";
|
||||
|
||||
if(argc < 2) {
|
||||
std::cout << "Keine Optionen angegeben." << std::endl;
|
||||
std::cout << " => Keine Unteroption angegeben." << std::endl;
|
||||
std::cout << "Aufruf: " << getProgramName(argv[0]) << " [Unteroption] [PARAMETER]" << std::endl;
|
||||
std::cout << "„" << getProgramName(argv[0]) << " (Unteroption) --help“ liefert weitere Informationen." << std::endl;
|
||||
std::cout << "„" << getProgramName(argv[0]) << " --help“ liefert weitere Informationen." << std::endl;
|
||||
settings.modus = Modus::EXIT;
|
||||
return settings;
|
||||
}
|
||||
if(compare("--help\ndefault\nurl\n--version", argv[1]) != 1) {
|
||||
std::cout << " => Unbekannte Unteroption: '" << argv[1] << "': Mehrere oder keine Option gefunden." << std::endl;
|
||||
std::cout << "Aufruf: " << getProgramName(argv[0]) << " [Unteroption] [PARAMETER]" << std::endl;
|
||||
std::cout << "„" << getProgramName(argv[0]) << " --help“ liefert weitere Informationen." << std::endl;
|
||||
settings.modus = Modus::EXIT;
|
||||
return settings;
|
||||
}
|
||||
|
||||
if(strcmp(argv[1], "--help") == 0) {
|
||||
if(strncmp(argv[1], "--help", strlen(argv[1])) == 0) {
|
||||
argv[1][0] = '\0';
|
||||
unterOption_help(&settings, argv[0]);
|
||||
return settings;
|
||||
|
||||
} else if (strcmp(argv[1], "default") == 0) {
|
||||
} else if (strncmp(argv[1], "default", strlen(argv[1])) == 0) {
|
||||
argv[1][0] = '\0';
|
||||
unterOption_default(&settings, argc, argv);
|
||||
return settings;
|
||||
|
||||
} else if (strcmp(argv[1], "url") == 0) {
|
||||
} else if (strncmp(argv[1], "url", strlen(argv[1])) == 0) {
|
||||
argv[1][0] = '\0';
|
||||
unterOption_url(&settings, argc, argv);
|
||||
return settings;
|
||||
|
||||
} else if (strcmp(argv[1], "--version") == 0) {
|
||||
std::cout << "Version 0.1.0" << std::endl;
|
||||
} else if (strncmp(argv[1], "--version", strlen(argv[1])) == 0) {
|
||||
std::cout << "Version: " << settings.version << std::endl;
|
||||
settings.modus = Modus::EXIT;
|
||||
return settings;
|
||||
} else {
|
||||
std::cout << "Unbekannte Unteroption: '" << argv[1] << "'" << std::endl;
|
||||
std::cout << "Aufruf: " << getProgramName(argv[0]) << " [Unteroption] [PARAMETER]" << std::endl;
|
||||
std::cout << "„" << getProgramName(argv[0]) << " (Unteroption) --help“ liefert weitere Informationen." << std::endl;
|
||||
std::cout << "Error: Invalid option " << argv[1] << ", but not detected in compare-Function" << std::endl;
|
||||
settings.modus = Modus::EXIT;
|
||||
return settings;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if(argc < 2) {
|
||||
std::cout << " => Kein Name angegeben" << std::endl;
|
||||
settings.modus = Modus::EXIT;
|
||||
return settings;
|
||||
}
|
||||
|
||||
settings.name = argv[1];
|
||||
|
||||
const option long_opts[] = {
|
||||
{"name", required_argument, nullptr, 'n'},
|
||||
{"output-file", required_argument, nullptr, 'o'},
|
||||
{"genau", required_argument, nullptr, 'g'},
|
||||
{"ip", required_argument, nullptr, 'i'},
|
||||
{"port", required_argument, nullptr, 'p'},
|
||||
{"episode", required_argument, nullptr, 'e'},
|
||||
{"end-episode", required_argument, nullptr, 'E'},
|
||||
{"season", required_argument, nullptr, 's'},
|
||||
{"end-season", required_argument, nullptr, 'S'},
|
||||
{"depth", required_argument, nullptr, 'D'},
|
||||
{"check-path", required_argument, nullptr, 'c'},
|
||||
{"muster", required_argument, nullptr, 'm'},
|
||||
{"infos", required_argument, nullptr, 'y'},
|
||||
{"list", required_argument, nullptr, 'l'},
|
||||
{"file", required_argument, nullptr, 'f'},
|
||||
{"search", required_argument, nullptr, 'b'},
|
||||
{"limit-dir", required_argument, nullptr, 'L'},
|
||||
{"languages", required_argument, nullptr, 't'},
|
||||
|
||||
{"only-one", no_argument, nullptr, 'd'},
|
||||
{"window", no_argument, nullptr, 'w'},
|
||||
{"hide", no_argument, nullptr, 'h'},
|
||||
{"remove-number", no_argument, nullptr, 'H'},
|
||||
{"no-color", no_argument, nullptr, 'C'},
|
||||
{"version", no_argument, nullptr, 'v'},
|
||||
{"v-check", no_argument, nullptr, 'V'},
|
||||
{"help", no_argument, nullptr, 'M'},
|
||||
|
||||
{nullptr, no_argument, nullptr, 0}
|
||||
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
int c = 0;
|
||||
while( ( c = getopt_long (argc, argv, "n:o:g:i:p:e:E:s:S:D:c:m:y:l:f:b:L:t:dwhHCvVM", long_opts, nullptr) ) != -1 ) {
|
||||
switch(c) {
|
||||
case 'n':
|
||||
//Name der Serie
|
||||
if(optarg) {
|
||||
settings.name=optarg;
|
||||
if(settings.name.find("/") != std::string::npos || settings.name.find("@") != std::string::npos || settings.name == "" ) {
|
||||
std::cout << " => Error: -n: Invalid Name: \"" << settings.Name.toStdString() << "\"." << std::endl;
|
||||
se;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'o':
|
||||
//Path zu Outputfile
|
||||
if(optarg)
|
||||
settings.OutputFile= optarg;
|
||||
break;
|
||||
case 'g':
|
||||
//Genaue Hoster
|
||||
|
||||
if(optarg) {
|
||||
if(!hasRevomedDefauldHoster) {
|
||||
settings.GenaueHoster.clear();
|
||||
hasRevomedDefauldHoster=true;
|
||||
}
|
||||
settings.GenaueHoster+= QString(optarg).replace("\n",",") + QString(",");
|
||||
}
|
||||
break;
|
||||
case 'i':
|
||||
//Ip Addresse for own Proxy settings
|
||||
if(optarg)
|
||||
settings.Proxy_IP= optarg;
|
||||
settings.Proxy_IP.replace("localhost","127.0.0.1");
|
||||
if(!settings.Proxy_IP.contains(".")) {
|
||||
std::cout << " => Error: -i: Invalid Ip Addresse: \"" << settings.Proxy_IP.toStdString() << "\"." << std::endl;
|
||||
return 38;
|
||||
}
|
||||
break;
|
||||
case 'p':
|
||||
//Port for own Proxy settings
|
||||
if(optarg) {
|
||||
settings.Proxy_Port= QString(optarg);
|
||||
char* p;
|
||||
strtol(settings.Proxy_Port.toStdString().c_str(), &p, 10);
|
||||
if (*p) {
|
||||
std::cout << "\33[2K\r" << " => Error: -p: Invalid Port: "<< settings.Proxy_Port.toStdString() << " ist keine Zahl." << std::endl;
|
||||
return 75;
|
||||
} else if(settings.Proxy_Port.toInt() < 0) {
|
||||
std::cout << "\33[2K\r" << " => Error: -p: Port ist negativ: \"" << settings.Proxy_Port.toStdString() << "\"." << std::endl;
|
||||
return 79;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'w':
|
||||
//Shows the MainWindow
|
||||
settings.show=true;
|
||||
break;
|
||||
case 'h':
|
||||
//Verbirgt ein Paar Infos(auch die redirect Links)
|
||||
settings.hide=true;
|
||||
break;
|
||||
case 'e':
|
||||
//Startet mit dieser Episode
|
||||
if(optarg) {
|
||||
char* p;
|
||||
long L = strtol(optarg, &p, 10);
|
||||
settings.StarteMitDieserFolge=static_cast<int>(L);
|
||||
|
||||
if (*p) {
|
||||
std::cout << " => Error: -e: Starterfolge ist keine Zahl: \"" << optarg << "\"." << std::endl;
|
||||
return 56;
|
||||
} else if(settings.StarteMitDieserFolge==0) {
|
||||
std::cout << " => Error: -e: Starterfolge ist 0." << std::endl;
|
||||
return 78;
|
||||
} else if(settings.StarteMitDieserFolge < 0) {
|
||||
std::cout << " => Error: -e: Starterfolge ist negativ: \"" << settings.StarteMitDieserFolge << "\"."<< std::endl;
|
||||
return 91;
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
case 's':
|
||||
//Startet mit dieser Staffel
|
||||
|
||||
if(optarg) {
|
||||
char* p;
|
||||
long L = strtol(optarg, &p, 10);
|
||||
settings.StarteMitDieserStaffel=static_cast<int>(L);
|
||||
|
||||
if (*p) {
|
||||
std::cout << " => Error: -s: Starterstaffel ist keine Zahl: \"" << optarg << "\"." << std::endl;
|
||||
return 57;
|
||||
} else if(settings.StarteMitDieserStaffel==0) {
|
||||
std::cout << " => Error: -s: Starterstaffel ist 0." << std::endl;
|
||||
return 79;
|
||||
} else if(settings.StarteMitDieserStaffel < 0) {
|
||||
std::cout << " => Error: -s: Starterstaffel ist negativ: \"" << settings.StarteMitDieserStaffel << "\"." << std::endl;
|
||||
return 92;
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
case 'E':
|
||||
//Stop mit dieser Folge
|
||||
|
||||
if(optarg) {
|
||||
char* p;
|
||||
long L = strtol(optarg, &p, 10);
|
||||
settings.StopNachFolge=static_cast<int>(L);
|
||||
|
||||
if (*p) {
|
||||
std::cout << " => Error: -E: Folge zum Stoppen ist keine Zahl: \"" << optarg << "\"." << std::endl;
|
||||
return 58;
|
||||
} else if(settings.StopNachFolge <= 0) {
|
||||
std::cout << " => Warnung: -E: Unmögliche Folge zum Stoppen: \"" << settings.StopNachFolge << "\"." << std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
case 'S':
|
||||
//Stopt mit dieser Staffel
|
||||
|
||||
if(optarg) {
|
||||
char* p;
|
||||
long L = strtol(optarg, &p, 10);
|
||||
settings.StopNachStaffel=static_cast<int>(L);
|
||||
|
||||
if (*p ) {
|
||||
std::cout << " => Error: -S: Staffel zum Stoppen ist keine Zahl: \"" << optarg << "\"." << std::endl;
|
||||
return 59;
|
||||
} else if(settings.StopNachStaffel <= 0) {
|
||||
std::cout << " => Warnung: -S: Unmögliche Staffel zum Stoppen: \"" << settings.StopNachStaffel << "\"."<< std::endl;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'd':
|
||||
//Macht nur 1nen genuaen Hoster pro Folge
|
||||
settings.OnlyOneHoster=true;
|
||||
break;
|
||||
case 'f':
|
||||
//Nimmt die Redirect Links von Parameter oder dem Path zu TextFile
|
||||
//UseFile=true;
|
||||
if(optarg)
|
||||
settings.PathToFile=optarg;
|
||||
break;
|
||||
case 'c':
|
||||
//Überprüft ob die Folge schon in dem Path exestiert
|
||||
if(optarg) {
|
||||
settings.CheckDir = optarg;
|
||||
}
|
||||
settings.use_default_with_check=true;
|
||||
break;
|
||||
case 'm':
|
||||
//Muster für das überprüfen ob ide Folge schon exestiert
|
||||
if(optarg) {
|
||||
if(std::string(optarg) == "all") {
|
||||
settings.Muster="S#Staffel#E#Folge#";
|
||||
break;
|
||||
}
|
||||
settings.Muster = optarg;
|
||||
}
|
||||
break;
|
||||
case 'l':
|
||||
//Listet alle Fehlenden Folgen in diesem Pfad auf
|
||||
if(optarg) {
|
||||
settings.CheckDir = optarg;
|
||||
}
|
||||
settings.use_checkmissing=true;
|
||||
break;
|
||||
case 'y':
|
||||
//Listet alle Staffel und deren Folgenanzahl einer Staffel auf
|
||||
settings.ShowSeans=true;
|
||||
if(optarg) {
|
||||
settings.Name=optarg;
|
||||
if(settings.Name.contains("/") || settings.Name.contains("@") || settings.Name.toStdString() == "") {
|
||||
std::cout << " => Error: -y: Invalid Name: \"" << settings.Name.toStdString() << "\"." << std::endl;
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case 'b':
|
||||
settings.SearchWindow=true;
|
||||
if(optarg) {
|
||||
settings.Name=optarg;
|
||||
if(settings.Name.contains("/") || settings.Name.contains("@") || settings.Name.toStdString() == "" ) {
|
||||
std::cout << " => Error: -b: Invalid Name: \"" << settings.Name.toStdString() << "\"." << std::endl;
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'L':
|
||||
if(optarg) {
|
||||
char* p;
|
||||
long L = strtol(optarg, &p, 10);
|
||||
settings.maxdir=static_cast<int>(L);
|
||||
|
||||
if (*p) {
|
||||
std::cout << " => Error: -L: Maximale Anzahl zu durchsuchende Ordner ist keine Zahl: \"" << optarg << "\"." << std::endl;
|
||||
return 56;
|
||||
} else if(settings.maxdir==0) {
|
||||
std::cout << " => Error: -L: Maximale Anzahl zu durchsuchende Ordner ist 0." << std::endl;
|
||||
return 78;
|
||||
} else if(settings.maxdir < 0) {
|
||||
std::cout << " => Error: -L: Maximale Anzahl zu durchsuchende Ordner ist negativ: \"" << settings.StarteMitDieserFolge << "\"."<< std::endl;
|
||||
return 91;
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case 'v':
|
||||
std::cout << " => Version: " << Version.toStdString() << std::endl;
|
||||
return 0;
|
||||
case 'D':
|
||||
|
||||
if(optarg) {
|
||||
char* p;
|
||||
long L = strtol(optarg, &p, 10);
|
||||
settings.Searchdepth=static_cast<int>(L);
|
||||
|
||||
if (*p ) {
|
||||
std::cout << " => Error: Suchtiefe ist keine Zahl: \"" << optarg << "\"." << std::endl;
|
||||
return 29;
|
||||
} else if(settings.Searchdepth <= 0) {
|
||||
std::cout << " => Error: Suchtiefe ist kleiner gleich 0: \"" << settings.Searchdepth << "\"." << std::endl;
|
||||
return 96;
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
case 'V':
|
||||
settings.CheckVersion=true;
|
||||
break;
|
||||
case 'C':
|
||||
settings.Color=false;
|
||||
break;
|
||||
case 'H':
|
||||
settings.BigHide=true;
|
||||
break;
|
||||
case 't':
|
||||
if(optarg) {
|
||||
settings.Languages=QString(optarg);
|
||||
}
|
||||
break;
|
||||
case 'M':
|
||||
listHelpmenue();
|
||||
return 0;
|
||||
default:
|
||||
//Falsche eingabe
|
||||
std::cout << "Aufruf: S_New2 [PARAMETER]" << std::endl;
|
||||
std::cout << "„S_New2 --help“ liefert weitere Informationen." << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(settings.GenaueHoster.lastIndexOf(',') != -1 && hasRevomedDefauldHoster)
|
||||
settings.GenaueHoster.remove(settings.GenaueHoster.lastIndexOf(','),1);
|
||||
|
||||
|
||||
return settings;*/
|
||||
}
|
||||
|
||||
|
||||
void listHelpmenue() {
|
||||
std::cout << "Aufruf: S_New2 [PARAMETER]" << std::endl
|
||||
<< std::endl
|
||||
<< "ALGEMEINE PARAMETER:" << std::endl
|
||||
<< std::endl
|
||||
|
||||
<< "\t-n [Name], --name [Name] " << std::endl
|
||||
<< "\t\tMit diesem Paramter gibt man den Namen einer Serie an." << std::endl
|
||||
<< "\t\tBei -c oder -l kann dieser Parameter weggelassen werden," << std::endl
|
||||
<< "\t\tfalls der Ordnername gleicher des Seriennamens ist." << std::endl
|
||||
<< std::endl
|
||||
|
||||
<< "\t-o [Pfad], --output-file [Pfad]" << std::endl
|
||||
<< "\t\tMit diesem Parameter gibt man den Pfad zu einem Text File an," << std::endl
|
||||
<< "\t\tdas nicht exestieren muss, in das alle genauen Links" << std::endl
|
||||
<< "\t\tgeschrieben werden sollen." << std::endl
|
||||
<< std::endl
|
||||
|
||||
<< "\t-g [Hoster Name], --genau [Hoster Name]" << std::endl
|
||||
<< "\t\tMit diesem Paramter gibt man die genauen Hoster, also die" << std::endl
|
||||
<< "\t\tRedirect Links, die zu den Links der Hoster umgewandelt" <<std::endl
|
||||
<< "\t\twerden sollen. -g mehrmals verwendbar oder mit , angeben." << std::endl
|
||||
<< "\t\tDer erste angegebene Hoster hat die größt Priorität." << std::endl
|
||||
<< "\t\tDer Zeite die zweitgrößte Priorität... ." << std::endl
|
||||
<< std::endl
|
||||
|
||||
<< "\t-d, --only-one" << std::endl
|
||||
<< "\t\tMit diesem Parameter wird nur 1 genauer Hoster pro Folge" << std::endl
|
||||
<< "\t\tgenommen. Der Parameter kann öfters verwendet werden, der" << std::endl
|
||||
<< "\t\tVorgang benötigt aber bei jedem Link etwas Zeit." << std::endl
|
||||
<< std::endl
|
||||
|
||||
<< "\t-i [Ip Addresse], --ip [Ip Addresse]" << std::endl
|
||||
<< "\t\tMit diesem Parameter kann man die Ip des Sock-5 Proxys ändern." << std::endl
|
||||
<< "\t\tStandert: 127.0.0.1" << std::endl
|
||||
<< std::endl
|
||||
|
||||
<< "\t-p [Port], --port [Port]" << std::endl
|
||||
<< "\t\tMit diesem Parameter kann man den Port des Sock-5 Proxys ändern." << std::endl
|
||||
<< "\t\tStandert: 9050" << std::endl
|
||||
<< std::endl
|
||||
|
||||
<< "\t-w, --window" << std::endl
|
||||
<< "\t\tMit diesem Paramter kann man das Window sichtbar machen." << std::endl
|
||||
<< "\t\tAber nicht während dem Ablauf darin herumtippen. (:" << std::endl
|
||||
<< std::endl
|
||||
|
||||
<< "\t-e [Folge], --episode [Folge]" << std::endl
|
||||
<< "\t\tMit diesem Parameter kann man festlegen," << std::endl
|
||||
<< "\t\tmit welcher Folge das Programm STARTET." << std::endl
|
||||
<< std::endl
|
||||
|
||||
<< "\t-E [Folge], --end-episode [Folge]" << std::endl
|
||||
<< "\t\tMit diesem Parameter kann man festlegen," << std::endl
|
||||
<< "\t\tmit welcher Folge das Programm STOPPT." << std::endl
|
||||
<< std::endl
|
||||
|
||||
<< "\t-s [Staffel], --season [Staffel]" << std::endl
|
||||
<< "\t\tMit diesem Parameter kann man festlegen," << std::endl
|
||||
<< "\t\tmit welcher Staffel das Programm STARTET." << std::endl
|
||||
<< std::endl
|
||||
|
||||
<< "\t-S [Staffel], --end-season [Staffel]" << std::endl
|
||||
<< "\t\tMit diesem Parameter kann man festlegen," << std::endl
|
||||
<< "\t\tmit welcher Staffel das Programm STOPPT." << std::endl
|
||||
<< std::endl
|
||||
|
||||
<< "\t-h, --hide" << std::endl
|
||||
<< "\t\tMit diesem Parameter werden die meisten Infos verborgen, auch" << std::endl
|
||||
<< "\t\tdie Redirectlinks.2>/dev/null am Ende verbirgt zusätzlich Infos." << std::endl
|
||||
<< std::endl
|
||||
|
||||
<< "\t-H, --remove-number" << std::endl
|
||||
<< "\t\tMit diesem Parameter werden die Staffel und Folgenangaben" << std::endl
|
||||
<< "\t\tbei den genauen Links verborgen. Auch bei: -o" << std::endl
|
||||
<< std::endl
|
||||
|
||||
<< "\t-D [Tiefe], --depth [Tiefe]" << std::endl
|
||||
<< "\t\tMit diesem Parameter kann man die Maximale Suchtiefe" << std::endl
|
||||
<< "\t\tvom durchsuchen der Ordner festlgen. Default: 4" << std::endl
|
||||
<< std::endl
|
||||
|
||||
<< "\t-C, --no-color" << std::endl
|
||||
<< "\t\tMit diesem Parameter kann man die Farbe ausschalten." << std::endl
|
||||
<< std::endl
|
||||
|
||||
<< "\t-m [Muster], --muster [Muster]" << std::endl
|
||||
<< "\t\tMit diesem Parameter kann man das Muster verändern, mit dem" << std::endl
|
||||
<< "\t\tÜberprüft wird, ob eine Folge exestiert." << std::endl
|
||||
<< "\t\t#Staffel# == Variable für die Staffel." << std::endl
|
||||
<< "\t\t#Folge# == Variable für die Folge." << std::endl
|
||||
<< "\t\tStandert Muster ist: S#Staffel#E#Folge#.mp4" << std::endl
|
||||
<< "\t\tonly \"all\" == ignore Format bei Deafault ==> S#Staffel#E#Folge#" << std::endl
|
||||
<< std::endl
|
||||
|
||||
<< "\t-L [Anzahl], --limit-dir [Anzahl]" << std::endl
|
||||
<< "\t\tMit diesem Parameter kann man die maximale Anzahl an" << std::endl
|
||||
<< "\t\tOrdnern angeben, die bei -c oder -l durchsucht werden." << std::endl
|
||||
<< "\t\tDefault: 100" << std::endl
|
||||
<< std::endl
|
||||
|
||||
<< "\t-t [Languages], --languages [Languages]" << std::endl
|
||||
<< "\t\tMit diesem Parameter kann man die Sprachen festlegen." << std::endl
|
||||
<< "\t\tDie Wichtigste zuert. [ GerDub | GerSub | Eng ] möglich." << std::endl
|
||||
<< "\t\tKommagetrennt schreiben. Default: GerDub,GerSub,Eng" << std::endl
|
||||
<< std::endl
|
||||
|
||||
<< "FUNKTIONEN:" << std::endl << std::endl
|
||||
|
||||
|
||||
<< "\t-n [Name], --name [Name]" << std::endl
|
||||
<< "\t\tDefault Modus:" << std::endl
|
||||
<< "\t\tParams: -n -o -g -d -i -p -w -e -E -s -S -h -H -C -t" << std::endl
|
||||
<< std::endl
|
||||
|
||||
<< "\t-c [Pfad], --check-path [Pfad]" << std::endl
|
||||
<< "\t\tMit diesem Parameter kann man einen Ordner angeben, indem" << std::endl
|
||||
<< "\t\tbereits gedownloadetet Folgen sind. Das Programm überprüft dann," << std::endl
|
||||
<< "\t\tbevor es einen Redirect Link zu einem Hoster Link macht, ob" << std::endl
|
||||
<< "\t\tdiese Folge in dem Ordner ist. Kein -n nötig, falls der" << std::endl
|
||||
<< "\t\tOrdnername gleich dem Seriennamen ist. Es verwendet beim" << std::endl
|
||||
<< "\t\tüberprüfen, ob eine Folge exestiert, das Muster von -m." << std::endl
|
||||
<< "\t\tAuch verwendbar mit *: /hom*/*/Dow*/ für /home/User/Downloads/." << std::endl
|
||||
<< "\t\tParams: -n -o -g -d -i -p -w -e -E -s -S -h -H -D -C -m -L -t" << std::endl
|
||||
<< std::endl
|
||||
|
||||
<< "\t-y [Name], --infos [Name]" << std::endl
|
||||
<< "\t\tMit diesem Parameter werden alle Staffeln einer Serie und deren" << std::endl
|
||||
<< "\t\tFolgen aufgelistet. Zusätzlich werden alle Namen der Folgen" << std::endl
|
||||
<< "\t\taufgelistet.Namen werden verborgen mit -h." << std::endl
|
||||
<< "\t\tParams: -n -o -i -p -w -h" << std::endl
|
||||
<< std::endl
|
||||
|
||||
<< "\t-l [Pfad], --list [Pfad]" << std::endl
|
||||
<< "\t\tMit diesem Parameter werden alle fehlenden Folgen in einem" << std::endl
|
||||
<< "\t\tOrdner aufgelistet. Kein -n nötig, falls der Ordnername gleich" << std::endl
|
||||
<< "\t\tdem Seriennamen ist." << std::endl
|
||||
<< "\t\tAuch verwendbar mit *: /hom*/*/Dow*/ für /home/User/Downloads/." << std::endl
|
||||
<< "\t\tParams: -n -o -i -p -w -e -E -s -S -h -D -C -m -L" << std::endl
|
||||
<< std::endl
|
||||
|
||||
<< "\t-f [Pfad/Url], --file [Pfad/Url] " << std::endl
|
||||
<< "\t\tMit diesem Parameter werden entweder alle Redirect-Links aus dem" << std::endl
|
||||
<< "\t\tim Parameter angegedenen Text File umgewandelt, oder direkt der" << std::endl
|
||||
<< "\t\tim Parameter angegebene Redirect-Link. Mehrere mit Komma" << std::endl
|
||||
<< "\t\tgetrennt schreiben." << std::endl
|
||||
<< "\t\tParams: -o -i -p -w -h" << std::endl
|
||||
<< std::endl
|
||||
|
||||
<< "\t-b [Name], --search [Name]" << std::endl
|
||||
<< "\t\tSucht Serien mit diesem Namen." << std::endl
|
||||
<< "\t\tParams: -n -i -p -w -C" << std::endl
|
||||
<< std::endl
|
||||
|
||||
<< "\t-v, --version" << std::endl
|
||||
<< "\t\tGibt die Verison des Programmes aus." << std::endl
|
||||
<< std::endl
|
||||
|
||||
<< "\t-V, --v-check" << std::endl
|
||||
<< "\t\tGibt die Version des Programmes & die neuste Version" << std::endl
|
||||
<<"\t\tdes Programmes aus." << std::endl
|
||||
<< std::endl
|
||||
|
||||
<< "\t-M, --help" << std::endl
|
||||
<< "\t\tGibt diese Helpmenü aus." << std::endl
|
||||
<< std::endl
|
||||
|
||||
<< std::endl << std::endl
|
||||
|
||||
<< "EINSTELLUNGEN/ACCOUNTS:" << std::endl << std::endl
|
||||
|
||||
<< "In dem Pfad " << getenv("HOME") << "/.config/S_New2/ sind Folgene Dateien:" << std::endl
|
||||
<< " => */Accounts:" << std::endl
|
||||
<< " In diesem File werden die s.to Accounts gespeichert." << std::endl
|
||||
<< " Eigene Accounts können hinzugefügt werden." << std::endl
|
||||
<< " => */Account_Number:" << std::endl
|
||||
<< " In diesem File wird die Nummer des zuletzt verwendeten" << std::endl
|
||||
<< " Accounts gespeichert, um zu verhindern, dass 1 Account" << std::endl
|
||||
<< " die ganze Zeit verwendet wird und dann Captchas kommen." << std::endl
|
||||
<< " => */Defaults:" << std::endl
|
||||
<< " In diesem File kann man standert einstellungen festlegen." << std::endl
|
||||
<< " Zeilen ohne = werden ignoriert. Wenn nach dem = nichts ist," << std::endl
|
||||
<< " Wird die Einstellung auch ignoriert." << std::endl
|
||||
<< " Mit noD als erstem Parameter kann man das Default File ignorieren." << std::endl
|
||||
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
|
||||
void unterOption_help(Settings *settings, char * argv0)
|
||||
{
|
||||
std::cout << "Aufruf: " << getProgramName(argv0) << " [Unteroption] [PARAMETER]" << std::endl << std::endl;
|
||||
std::cout << "Unteroptionen:" << std::endl
|
||||
<< "\t„--help“" << std::endl
|
||||
<< "\t„default“" << std::endl
|
||||
<< "\t„url“" << std::endl
|
||||
<< "\t„--version“" << std::endl;
|
||||
<< "\t„--help“\tListe aller Unteroptionen" << std::endl
|
||||
<< "\t„--version“\tVersion des Programmes" << std::endl
|
||||
<< "\t„url“\t\tModus um eigene Redirect-Links umzuwandeln." << std::endl
|
||||
<< "\t„default“\tModus um Links von Serien zu bekommen." << std::endl;
|
||||
settings->modus = Modus::EXIT;
|
||||
}
|
||||
|
||||
|
||||
void unterOption_default(Settings *settings, int argc, char ** argv)
|
||||
{
|
||||
settings->modus = Modus::DEFAULT_MODUS;
|
||||
if(settings->modus)
|
||||
std::cout << "Modus: DEFAULT_MODUS" << std::endl;
|
||||
|
||||
int c = 0;
|
||||
const option long_opts[] = {
|
||||
@ -566,22 +80,33 @@ void unterOption_default(Settings *settings, int argc, char ** argv)
|
||||
{"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'},
|
||||
|
||||
|
||||
{"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:i:p:g:l:o:hc", long_opts, nullptr) ) != -1 ) {
|
||||
while( ( c = getopt_long (argc, argv, "n:i:p:g:l:o:e:E:s:S:hcd", long_opts, nullptr) ) != -1 ) {
|
||||
switch(c) {
|
||||
case 'n':
|
||||
if(optarg)
|
||||
settings->name = optarg;
|
||||
if(settings->modus)
|
||||
std::cout << "Name: " << settings->name << std::endl;
|
||||
break;
|
||||
case 'i':
|
||||
if(optarg)
|
||||
settings->proxy_ip = optarg;
|
||||
if(settings->modus)
|
||||
std::cout << "Proxy Ip Addresse: " << settings->proxy_ip << std::endl;
|
||||
break;
|
||||
case 'p':
|
||||
if(optarg)
|
||||
@ -591,23 +116,103 @@ void unterOption_default(Settings *settings, int argc, char ** argv)
|
||||
settings->modus = Modus::EXIT;
|
||||
return;
|
||||
}
|
||||
if(settings->modus)
|
||||
std::cout << "Proxy Port: " << settings->proxy_port << std::endl;
|
||||
break;
|
||||
case 'g':
|
||||
if(optarg)
|
||||
settings->genaueHoster =+ optarg + std::string(",");
|
||||
if(settings->modus)
|
||||
std::cout << "Hosterreihenfolge: " << settings->genaueHoster << std::endl;
|
||||
break;
|
||||
case 'l':
|
||||
if(optarg)
|
||||
settings->languages =+ optarg + std::string(",");
|
||||
if(settings->modus)
|
||||
std::cout << "Sprachenreihenfolge: " << settings->languages << std::endl;
|
||||
break;
|
||||
case 'o':
|
||||
if(optarg)
|
||||
settings->outputFilePath = optarg;
|
||||
break;
|
||||
case 'c':
|
||||
settings->colorless = true;
|
||||
if(settings->modus)
|
||||
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;
|
||||
settings->modus = Modus::EXIT;
|
||||
return;
|
||||
} else if (settings->startEpisode == 0) {
|
||||
std::cout << "Error: -e [Folge]: StartEpisode ist 0." << std::endl;
|
||||
settings->modus = Modus::EXIT;
|
||||
return;
|
||||
} else if (settings->startEpisode < 0) {
|
||||
std::cout << "Error: -e [Folge]: StartEpisode " << settings->startEpisode << " ist kleiner 0." << std::endl;
|
||||
settings->modus = Modus::EXIT;
|
||||
return;
|
||||
}
|
||||
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;
|
||||
settings->modus = Modus::EXIT;
|
||||
return;
|
||||
} 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;
|
||||
settings->modus = Modus::EXIT;
|
||||
return;
|
||||
} else if (settings->startSeason == 0) {
|
||||
std::cout << "Error: -s [Staffel]: StartStaffel ist 0." << std::endl;
|
||||
settings->modus = Modus::EXIT;
|
||||
return;
|
||||
} else if (settings->startSeason < 0) {
|
||||
std::cout << "Error: -s [Staffel]: StartStaffel " << settings->startSeason << " ist kleiner 0." << std::endl;
|
||||
settings->modus = Modus::EXIT;
|
||||
return;
|
||||
}
|
||||
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;
|
||||
settings->modus = Modus::EXIT;
|
||||
return;
|
||||
} else if(settings->debugMode)
|
||||
std::cout << "StopSeason: " << settings->stopSeason << std::endl;
|
||||
break;
|
||||
|
||||
|
||||
case 'c':
|
||||
settings->colorless = true;
|
||||
if(settings->modus)
|
||||
std::cout << "Farblos: true" << std::endl;
|
||||
break;
|
||||
case 'd':
|
||||
settings->debugMode = true;
|
||||
if(settings->modus)
|
||||
std::cout << "Debug Modus: true" << std::endl;
|
||||
break;
|
||||
case 'h':
|
||||
unterOption_default_help(settings, argv[0]);
|
||||
return;
|
||||
@ -620,41 +225,118 @@ void unterOption_default(Settings *settings, int argc, char ** argv)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void unterOption_default_help(Settings *settings, char * argv0)
|
||||
{
|
||||
std::cout << getProgramName(argv0) << " default: " << std::endl
|
||||
<< "\t-n, --name \t\t[Name]" << std::endl
|
||||
<< "\t-i, --ip-addresse \t[IP]\t\t\t Default: 127.0.0.1" << std::endl
|
||||
<< "\t-p, --port \t\t[Port]\t\t\t Default: 9050" << std::endl
|
||||
<< "\t-g, --genauer-hoster \t[Hoster1,Hoster2,...]" << std::endl
|
||||
<< "\t-l, --languages \t[GerSub/GerDub/Eng,...]\t Default: GerDub,GerSub,Eng" << std::endl
|
||||
<< "\t-o, --output-file \t[Pfad]" << std::endl
|
||||
<< "\t-c, --colorless\t\t\t\t\t Default: false" << std::endl
|
||||
std::cout << "Usage: " << getProgramName(argv0) << " default [ Parameter & {-n [Name]} ]..." << std::endl
|
||||
<< "Parameter:" << std::endl << std::endl
|
||||
<< " > Muss-Parameter:" << std::endl
|
||||
<< "\t-n [Name], --name [Name]" << std::endl
|
||||
<< "\t -> Namen der Serie, deren Links du willst." << 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-l [GerSub/GerDub/Eng,...], --languages [GerSub/GerDub/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-i [ProxyIPAddresse], --ip-addresse [ProxyIPAddresse]" << std::endl
|
||||
<< "\t -> Ip Addresse eines Socks5-Proxys angeben. Default: 127.0.0.1" << std::endl
|
||||
<< "\t-p [ProxyPort], --port [ProxyPort]" << std::endl
|
||||
<< "\t -> Port eines Socks5-Proxy angeben. Default: 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
|
||||
<< " > 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
|
||||
<< std::endl
|
||||
<< " > Help-Optionen" << std::endl
|
||||
<< "\t-h, --help" << std::endl;
|
||||
|
||||
|
||||
settings->modus = Modus::EXIT;
|
||||
}
|
||||
|
||||
|
||||
void unterOption_url(Settings *settings, int argc, char **argv)
|
||||
{
|
||||
settings->modus = Modus::DIRECT_LINK_MODUS;
|
||||
if(settings->modus)
|
||||
std::cout << "Modus: DIRECT_LINK_MODUS" << std::endl;
|
||||
|
||||
int c = 0;
|
||||
const option long_opts[] = {
|
||||
{"url", required_argument, nullptr, 'u'},
|
||||
{"ip-addresse", required_argument, nullptr, 'i'},
|
||||
{"port", 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, "u:h", long_opts, nullptr) ) != -1 ) {
|
||||
while( ( c = getopt_long (argc, argv, "u:i:p:o:hcd", long_opts, nullptr) ) != -1 ) {
|
||||
switch(c) {
|
||||
case 'u':
|
||||
if(optarg)
|
||||
settings->name = optarg;
|
||||
if(settings->modus)
|
||||
std::cout << "Urls: " << settings->name << std::endl;
|
||||
break;
|
||||
|
||||
case 'i':
|
||||
if(optarg)
|
||||
settings->proxy_ip = optarg;
|
||||
if(settings->modus)
|
||||
std::cout << "Proxy Ip Addresse: " << settings->proxy_ip << std::endl;
|
||||
break;
|
||||
case 'p':
|
||||
if(optarg)
|
||||
settings->proxy_port = std::to_string( atoi( optarg ) );
|
||||
if(settings->proxy_port != optarg) {
|
||||
std::cout << "Invalid Port: " << optarg << std::endl;
|
||||
settings->modus = Modus::EXIT;
|
||||
return;
|
||||
}
|
||||
if(settings->modus)
|
||||
std::cout << "Proxy Port: " << settings->proxy_port << std::endl;
|
||||
break;
|
||||
case 'o':
|
||||
if(optarg)
|
||||
settings->outputFilePath = optarg;
|
||||
if(settings->modus)
|
||||
std::cout << "Pfad zu Output-Datei: " << settings->outputFilePath << std::endl;
|
||||
break;
|
||||
case 'c':
|
||||
settings->colorless = true;
|
||||
if(settings->modus)
|
||||
std::cout << "Farblos: true" << std::endl;
|
||||
break;
|
||||
case 'd':
|
||||
settings->debugMode = true;
|
||||
if(settings->modus)
|
||||
std::cout << "Debug Modus: true" << std::endl;
|
||||
break;
|
||||
case 'h':
|
||||
unterOption_url_help(settings, argv[0]);
|
||||
@ -670,9 +352,16 @@ void unterOption_url(Settings *settings, int argc, char **argv)
|
||||
|
||||
void unterOption_url_help(Settings *settings, char * argv0)
|
||||
{
|
||||
std::cout << getProgramName(argv0) <<" url: " << std::endl
|
||||
<< "\t-u, --url [Url1,Url2]" << std::endl
|
||||
<< "\t-h, --help" << std::endl;
|
||||
std::cout << "Usage: " << getProgramName(argv0) << " url [ Parameter & {-u [Url]} ]..." << std::endl
|
||||
<< "Parameter" << std::endl
|
||||
<< "\t-u [Url1,Url2,...], \t--url [Url1,Url2,...]" << std::endl
|
||||
<< "\t-i [ProxyIPAddresse], \t--ip-addresse [ProxyIPAddresse] Default: 127.0.0.1" << std::endl
|
||||
<< "\t-p [ProxyPort], \t--port [ProxyPort]\t\t Default: 9050" << std::endl
|
||||
<< "\t-o [Pfad], \t\t--output-file [Pfad]" << std::endl
|
||||
<< "\t-c, \t\t\t--colorless\t\t\t Default: false" << std::endl
|
||||
<< "\t-d, \t\t\t--debug-mode\t\t\t Default: false" << std::endl
|
||||
<< "\t -> Debug Nachrichten an." << std::endl
|
||||
<< "\t-h, \t\t\t--help" << std::endl;
|
||||
settings->modus = Modus::EXIT;
|
||||
}
|
||||
|
||||
@ -681,3 +370,15 @@ std::string getProgramName(char *argv0)
|
||||
{
|
||||
return std::string(argv0).erase(0, ( (std::string(argv0).find_last_of("/\\") != std::string::npos ) ? std::string(argv0).find_last_of("/\\") +1 : 0 ) );
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include <iostream>
|
||||
#include <getopt.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sstream>
|
||||
|
||||
enum Modus {
|
||||
EXIT = -1,
|
||||
@ -18,22 +18,33 @@ struct Settings {
|
||||
Settings(std::string name) : name(name) {}
|
||||
|
||||
std::string name,
|
||||
accountFilePath = "/home/markus/a",
|
||||
accountFilePath = "/tmp/a",
|
||||
accountNumberPath= "/tmp/b",
|
||||
cookieFilePath = "/tmp/S_New4_cookies",
|
||||
proxy_ip = "127.0.0.1",
|
||||
proxy_port = "9050",
|
||||
genaueHoster,
|
||||
languages = "GerDub,GerSub,Eng",
|
||||
genaueHoster,
|
||||
version = "1.0.1",
|
||||
outputFilePath;
|
||||
Modus modus = Modus::DEFAULT_MODUS;
|
||||
bool colorless = false;
|
||||
bool colorless = false,
|
||||
debugMode = false;
|
||||
int startEpisode = 1,
|
||||
stopEpisode = 0,
|
||||
startSeason = 1,
|
||||
stopSeason = 0;
|
||||
|
||||
|
||||
};
|
||||
|
||||
Settings manageParameter(int argc, char ** argv);
|
||||
std::string getProgramName(char * argv0);
|
||||
int compare(std::string All_Options_with_komma_between, std::string input);
|
||||
|
||||
|
||||
void unterOption_help(Settings * settings, char *argv0);
|
||||
|
||||
|
||||
void unterOption_default(Settings * settings, int argc, char **argv);
|
||||
void unterOption_default_help(Settings * settings, char * argv0);
|
||||
|
||||
|
@ -19,8 +19,15 @@ int ProgramManager::start(Settings setting)
|
||||
|
||||
int ProgramManager::defaultModus(Settings *settings)
|
||||
{
|
||||
AccountManager accountManager(settings->accountFilePath);
|
||||
AccountManager accountManager(settings->accountFilePath, settings->accountNumberPath);
|
||||
pageManager.setProxy(settings->proxy_ip, settings->proxy_port);
|
||||
pageManager.setCookieFilePath(settings->cookieFilePath);
|
||||
pageManager.setDebugMode(settings->debugMode);
|
||||
|
||||
if(settings->name == "") {
|
||||
std::cout << "Kein Name angegeben: Missing Parameter -n [Name]." << std::endl;
|
||||
return 27;
|
||||
}
|
||||
|
||||
std::string nameInUrl =pageManager.checkName(settings->name);
|
||||
if(nameInUrl == "-1")
|
||||
@ -34,16 +41,22 @@ int ProgramManager::defaultModus(Settings *settings)
|
||||
if(tmp_reply.html == "-1")
|
||||
return 32;
|
||||
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 = 1; staffel <= maxStaffel; ++staffel) {
|
||||
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 = 1; folge <= maxFolge; ++folge) {
|
||||
for (int folge = settings->startEpisode; folge <= maxFolge; ++folge) {
|
||||
|
||||
tmp_reply =pageManager.getServerRequest(pageManager.UrlPraefix + nameInUrl + "/staffel-" + std::to_string(staffel) + "/episode-" + std::to_string(folge));
|
||||
if(tmp_reply.html == "-1")
|
||||
@ -51,12 +64,24 @@ int ProgramManager::defaultModus(Settings *settings)
|
||||
std::string allLinks = pageManager.getLinks(tmp_reply.html);
|
||||
std::string Link = pageManager.chooseHosterLink(allLinks, settings->genaueHoster, settings->languages);
|
||||
|
||||
std::cout << " -> Link: https://s.to" << Link << std::endl;
|
||||
if(settings->debugMode)
|
||||
std::cout << allLinks << std::endl << " -> Link: '" << ( (Link == "") ? "" : "https://s.to") << Link << "'" << std::endl;
|
||||
if(convertLink(Link, &accountManager, settings, staffel, folge, allLinks) != 0)
|
||||
return 51;
|
||||
|
||||
} std::cout << "season: " << staffel << " hat " << maxFolge << " folgen" << std::endl;
|
||||
if(folge == settings->stopEpisode && settings->stopSeason < 1) // stoppe wenn stopfolge gleich der folge ist und stopstaffel nicht gesetzt wurde.
|
||||
return 0;
|
||||
else if ( folge == settings->stopEpisode && staffel == settings->stopSeason) // stoppe wenn stopfolge = folge && stopstaffel == staffel
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -64,7 +89,16 @@ int ProgramManager::defaultModus(Settings *settings)
|
||||
|
||||
int ProgramManager::directLinkModus(Settings *settings)
|
||||
{
|
||||
AccountManager accountManager(settings->accountFilePath);
|
||||
AccountManager accountManager(settings->accountFilePath, settings->accountNumberPath);
|
||||
pageManager.setCookieFilePath(settings->cookieFilePath);
|
||||
pageManager.setProxy(settings->proxy_ip, settings->proxy_port);
|
||||
pageManager.setDebugMode(settings->debugMode);
|
||||
|
||||
if(settings->name == "") {
|
||||
std::cout << "Kein(e) Link(s) angegeben: Missing Parameter -u [Url]." << std::endl;
|
||||
return 76;
|
||||
}
|
||||
|
||||
std::istringstream iStrStream( pageManager.replace( settings->name, ",", "\n" ) + "\n" );
|
||||
std::string line;
|
||||
|
||||
@ -90,7 +124,18 @@ int ProgramManager::convertLink(std::string redirectLink, AccountManager * accou
|
||||
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) {
|
||||
std::cout << " => " << ( (allLinks == "" ) ? "\033[31mKEINEN" : "\033[33mKeinen PASSENDEN" ) << " Hoster für die Folge " << folgenID << " gefunden." << "\033[0m" << std::endl;
|
||||
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
|
||||
<< allLinks << 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;
|
||||
}
|
||||
|
||||
@ -99,6 +144,8 @@ int ProgramManager::convertLink(std::string redirectLink, AccountManager * accou
|
||||
if (newUrl == "-1") {
|
||||
return 102;
|
||||
} else if(newUrl.find("/s.to/redirect/") != std::string::npos ) {
|
||||
if(settings->debugMode)
|
||||
std::cout << "Redirect Link nach umwandlung --> Neuer Account" << std::endl;
|
||||
if(pageManager.login(accountManager->getNextAccount()) != 0)
|
||||
return -1;
|
||||
continue;
|
||||
@ -106,7 +153,7 @@ int ProgramManager::convertLink(std::string redirectLink, AccountManager * accou
|
||||
else {
|
||||
std::cout << " => " << folgenID << green << newUrl << "\033[0m" << std::endl;
|
||||
if(settings->outputFilePath != "")
|
||||
if(pageManager.writeToFile(folgenID + settings->outputFilePath, newUrl) != 0)
|
||||
if(pageManager.writeToFile(settings->outputFilePath,folgenID + newUrl) != 0)
|
||||
return 108;
|
||||
return 0;
|
||||
}
|
||||
@ -139,9 +186,6 @@ int ProgramManager::convertLink(std::string redirectLink, AccountManager * accou
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user