def-file: v2.5
- change current domain names
- add auto tor login change when cloudflare ( maybe later option to turn
off this fuction )
- fix smal outdated doc errors
This commit is contained in:
M4RKUS28
2023-09-12 04:22:53 +02:00
parent 43ab7ae760
commit 925b9fec72
22 changed files with 675 additions and 388 deletions

View File

@ -1,6 +1,12 @@
QT -= gui
QT -= gui core
#CONFIG += -static -libstdc++ -static-libgcc #-static
#QT += core gui
#greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
#QT += webenginewidgets
#Linux:
unix: LIBS += -lcurl

View File

@ -1,8 +1,13 @@
#include "programManager.h"
//#include <QApplication>
int main(int argc, char *argv[])
{
// QApplication a(argc, argv);
ProgramManager mainProgram;
Settings settings;
int res = manageParameter(settings, argc, argv);

View File

@ -1,10 +1,18 @@
#include "pageManager.h"
std::string PageManager::torAnmeldeNamen = "no-name";
bool PageManager::cloudflare_protec = false;
std::mutex PageManager::torAnmeldeNamenMutex;
PageManager::PageManager(std::string sock5ProxyOnlyAddress)
: sock5Proxy("socks5://" + sock5ProxyOnlyAddress)
{
std::srand(std::time(0)); // Seed the random number generator
curl_global_init(CURL_GLOBAL_ALL);
if(false)
std::cout << "PageManager()" << std::endl;
}
@ -25,7 +33,7 @@ void PageManager::setProxy(std::string ip, int port)
} else {
this->sock5Proxy = "socks5://" + ip + ":" + std::to_string(port);
if(debugMode)
std::cout << "Proxy: " << ip << ":" << port << std::endl;
std::cout << "Proxy: " << ip << ":" << port << " -> ADDR of PM:" << this << std::endl;
}
}
@ -57,6 +65,7 @@ static size_t write_data(void *ptr, size_t size, size_t nmemb, void *stream)
#if defined(_WIN32)
//#define WIN32_LEAN_AND_MEAN
//#define VC_EXTRALEAN
//#include <QUrl>
#include <Windows.h>
#elif defined(__linux__)
#include <sys/ioctl.h>
@ -79,10 +88,16 @@ void PageManager::get_terminal_size(int& width) {
#endif // Windows/Linux
}
Reply PageManager::getServerRequest(std::string protocol, std::string Url, bool useCookies, std::string data, bool generateCookieFile, bool UrlAfterRedirectOnlyNeeded, std::string cookieFilePath)
Reply PageManager::getServerRequest(std::string protocol, std::string Url, bool useCookies, std::string data, bool generateCookieFile, bool UrlAfterRedirectOnlyNeeded, std::string cookieFilePath, int rek_num)
{
Url = protocol + Url; // add https://
if(rek_num > 15) {
if(debugMode)
std::cout << " -> EXIT(): Out of trys..." << std::endl;
exit(0);
}
CURL *curl;
CURLcode res;
std::string readBuffer;
@ -105,10 +120,22 @@ Reply PageManager::getServerRequest(std::string protocol, std::string Url, bool
}
//Settings
if(sock5Proxy != "")
if(sock5Proxy != "") {
curl_easy_setopt(curl, CURLOPT_PROXY, sock5Proxy.c_str() ); //Sock5Proxy für Curl
else if(debugMode)
std::cout << "\33[2K\r => INFO: Es wird kein Proxy verwendet." << std::endl;
if(cloudflare_protec) {
CURLcode setoptResult = curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, (torAnmeldeNamen + ":passwd").c_str());
if (setoptResult != CURLE_OK) {
std::cerr << "Setting CURLOPT_URL failed: " << curl_easy_strerror(setoptResult) << std::endl;
}
}
} else {
if(debugMode)
std::cout << "\33[2K\r => INFO: Es wird kein Proxy verwendet: ADDR of PM:" << this << " -> prox: " << sock5Proxy << std::endl;
}
//curl_easy_setopt(curl, CURLOPT_FAILONERROR, true); // html errors to errorcode res
//curl_easy_setopt(curl, CURLOPT_NOPROGRESS, false); // Progressausgabe aktivieren
@ -119,12 +146,12 @@ Reply PageManager::getServerRequest(std::string protocol, std::string Url, bool
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0);
#endif
curl_easy_setopt(curl, CURLOPT_URL, Url.c_str()); //Url 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 10.0; Win64; x64; rv:80.0) Gecko/20100101 Firefox/80.0");
curl_easy_setopt(curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36");
/*"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:100.0) Gecko/20100101 Firefox/100.0" */
if(useCookies)
curl_easy_setopt(curl, CURLOPT_COOKIEFILE, cookieFilePath.c_str());
if(data != "")
@ -136,7 +163,8 @@ Reply PageManager::getServerRequest(std::string protocol, std::string Url, bool
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;
std::cout << "\33[2K\r " << std::flush;
if(res != CURLE_OK) {
if(timeout == maxTimeout) {
@ -164,7 +192,7 @@ Reply PageManager::getServerRequest(std::string protocol, std::string Url, bool
}
}
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;
std::cout << "\33[2K\r " << std::string( " => Warning: Versuch " + std::to_string(timeout) + " von " + std::to_string(maxTimeout) + ": curl_easy_perform() failed: " + curl_easy_strerror(res) )<< std::endl;
sleep(1);
}
} else {
@ -185,6 +213,37 @@ Reply PageManager::getServerRequest(std::string protocol, std::string Url, bool
/* always cleanup */ /* Mach den Griff zu, schreib die Kekse! */
curl_easy_cleanup(curl);
if(returnUrl.find("/_ray/pow") != std::string::npos) {
std::cout << " \33[2K\r => CLOUD FLARE PROTECTION (Try " << rek_num << "/15)..." << std::flush;
usleep(400000);
if(this->debugMode && Url != "ifconfig.me/ip") {
std::string out_ip = this->getServerRequest("https://", "ifconfig.me/ip").html;
if(out_ip.find("<html>") == std::string::npos && [](const std::string& str) { return std::count(str.begin(), str.end(), '.'); }(out_ip) == 3)
std::cout << "\33[2K\r -> Current IP: " << out_ip << std::endl;
else
std::cout << "\33[2K\r -> Current IP: " << "Unknown: " << std::endl;
}
cloudflare_protec = true;
generateNewTorAnmeldeNamen(torAnmeldeNamen);
return this->getServerRequest("", Url, useCookies, data, generateCookieFile, UrlAfterRedirectOnlyNeeded,cookieFilePath, rek_num + 1);
// std::cout << "/_ray/pow:\n" << readBuffer << std::endl;
// this->writeToFile( std::vector<std::string>{"./output.text"}, readBuffer );
// QWebEngineView view;
// view.load(QUrl("https://qt-project.org/"));
// view.resize(1024, 750);
// view.show();
// qApp->exec();
}
return Reply(readBuffer, returnUrl);
}
@ -238,7 +297,7 @@ int PageManager::downLoadToFile(std::string filePath, std::string url)
std::cout << "\33[2K\r => INFO: Proxy:'" << sock5Proxy << "'" << std::endl;
//User Agent
curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:80.0) Gecko/20100101 Firefox/80.0");
curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:100.0) Gecko/20100101 Firefox/100.0");
/* write the page body to this file handle */
curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, pagefile);
@ -346,6 +405,8 @@ checkNameRply PageManager::checkName(std::vector<PAGE> &pages, std::string Name,
} else if( html.find("<!DOCTYPE html><html><head><title>DDOS-GUARD</title>") != std::string::npos ) {
std::cout << "\33[2K\r" <<" => WARNUNG: Die Seite : '" << pages.at(i).url << "' benötigt ein DDOS-GUARD hCaptcha!" << std::endl;
writeToFile( outPutFilePaths, html );
pages.erase(pages.begin() + i);
i--;
continue;

View File

@ -1,6 +1,7 @@
#ifndef MANAGEPAGE_H
#define MANAGEPAGE_H
#pragma once
#include "accountManager.h"
#include "parameterManager.h" // for isNumber
@ -20,6 +21,7 @@
#include <unistd.h> // sleep
#include <algorithm>
#include <ctime> // std::time, localtime ...
#include <mutex>
struct Reply {
@ -53,7 +55,7 @@ public:
void get_terminal_size(int& width);
Reply getServerRequest(std::string protocol, std::string Url, bool useCookies = false, std::string data = "", bool generateCookieFile = false, bool UrlAfterRedirectOnlyNeeded = false, std::string cookieFilePath = "");
Reply getServerRequest(std::string protocol, std::string Url, bool useCookies = false, std::string data = "", bool generateCookieFile = false, bool UrlAfterRedirectOnlyNeeded = false, std::string cookieFilePath = "", int rek_num = 0);
int downLoadToFile(std::string filePath, std::string url);
int login(PAGE page, Account account, std::string cookieFilePath);
@ -75,9 +77,41 @@ public:
static std::string getCurlVersion();
static std::mutex torAnmeldeNamenMutex;
static std::string torAnmeldeNamen;
static bool cloudflare_protec;
static std::string generateRandomString(int length) {
static const char alphanum[] =
"0123456789"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz";
std::string randomString;
for (int i = 0; i < length; ++i) {
randomString.push_back(alphanum[std::rand() % (sizeof(alphanum) - 1)]);
}
return randomString;
}
static void generateNewTorAnmeldeNamen(std::string alterName) {
torAnmeldeNamenMutex.lock();
if(torAnmeldeNamen == alterName) {
torAnmeldeNamen = generateRandomString(10);
std::cout << " -> New Proxy Login Name: " << torAnmeldeNamen << std::flush;
usleep(700000);
}
torAnmeldeNamenMutex.unlock();
}
std::string sock5Proxy;
private:
bool debugMode = false;
};
#endif // MANAGEPAGE_H

View File

@ -1,5 +1,6 @@
#include "parameterManager.h"
int setPaths(Settings &settings)
{
//Path settings
@ -167,7 +168,7 @@ void unterOption_printVersion(Settings &settings)
<< " > Defaults Datei Version: \t" << settings.defaultFileVersion << std::endl
#ifdef __MINGW_GCC_VERSION
<< " > MINGW GCC Version: \t" <<__GNUC__ << "." << __GNUC_MINOR__ << "." << __GNUC_PATCHLEVEL__ << std::endl
<< " > MINGW GCC Version: \t\t" <<__GNUC__ << "." << __GNUC_MINOR__ << "." << __GNUC_PATCHLEVEL__ << std::endl
#endif
<< " > Curl Version: \t\t" << PageManager::getCurlVersion() << std::endl
@ -221,7 +222,7 @@ int loadDefaulOptions(Settings &settings)
ofs << "# Der Priorität nach angeben! Tipp: Erst Anime, dann Alle-Serien" << std::endl;
ofs << "# Kombinierbar mit -f - Verwende erste Seite" << std::endl;
ofs << "# Unterstützte Seiten:" << std::endl;
ofs << "# anicloud.io, s.to, 190.115.18.20, serienstream.to, serien.cam, all" << std::endl;
ofs << "# aniworld.to, s.to, 186.2.175.5, serienstream.to, all" << std::endl;
ofs << "Internetseiten=AniWorld.to,serienstream.to" << std::endl << std::endl;
ofs << "# -> Standart Wert für Parameter: -f, --use-first:" << std::endl;
@ -240,7 +241,7 @@ int loadDefaulOptions(Settings &settings)
ofs << "#" << std::endl << "# -> Einstellungen für default Modus:" << std::endl << "#" << std::endl << std::endl;
ofs << "# -> Standart Wert für Parameter: -g, --genaue-hoster:" << std::endl;
ofs << "default_GenaueHoster=VOE,Vidoza" << std::endl << std::endl;
ofs << "default_GenaueHoster=VOE" << std::endl << std::endl;
ofs << "# -> Standart Wert für Parameter: -l, --languages:" << std::endl;
ofs << "default_Sprachen=GerDub,GerSub,Eng" << std::endl << std::endl;
@ -257,7 +258,7 @@ int loadDefaulOptions(Settings &settings)
ofs << "#" << std::endl << "# -> Einstellungen für search Modus:" << std::endl << "#" << std::endl << std::endl;
ofs << "# -> Standart Wert für Parameter: -e, --exactly-writing:" << std::endl;
ofs << "#search-AchteAufGroßUndKleinschreibung=false" << std::endl << std::endl;
ofs << "search-AchteAufGroßUndKleinschreibung=false" << std::endl << std::endl;
ofs << "# -> Aktiviert werden bei der Suche sämtliche Namen der Serie angezeigt." << std::endl;
ofs << "# Bei Animes kann das zu Mehrzeiligen ausgaben pro Serie führen!" << std::endl;
@ -441,7 +442,7 @@ int unterOption_help(Settings &settings)
<< " -> 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
<< " serienstream.sx und anicloud.io umwandeln." << std::endl
<< " serienstream.to und aniworld.to umwandeln." << std::endl
<< std::endl;
std::cout << "Unteroptionen:" << std::endl
@ -894,8 +895,8 @@ void unterOption_url_help(std::string programName)
std::cout << "Beschreibung:" << std::endl
<< " Mit dieser Unterfunktion von " << programName << " können eigene" << std::endl
<< " Redirect-Links umgewandelt werden. Beispiel:" << std::endl
<< " https://serienstream.sx/redirect/44498xy -> https://vivolvox.xy/123xy" << std::endl
<< " Der Link kann folgen Aussehen: {[*]serienstream.sx}/redirect/[*]." << std::endl
<< " https://serienstream.tx/redirect/44498xy -> https://vivolvox.xy/123xy" << std::endl
<< " Der Link kann folgen Aussehen: {[*]serienstream.to}/redirect/[*]." << std::endl
<< " Standartwerte können im Defaultfile geändert werden." << std::endl << std::endl;
std::cout << "INTERNETSEITEN OPTIONEN:" << std::endl
@ -1028,10 +1029,10 @@ void unterOption_search_help(std::string programName)
std::cout << "Beschreibung:" << std::endl
<< " Mit dieser Unterfunktion des Programms kann man Serien auf serienstream.sx suchen." << std::endl
<< " Mit dieser Unterfunktion des Programms kann man Serien auf serienstream.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 serienstream.sx ist, und deshalb nicht gefunden" << std::endl
<< " Tipp: Wenn deine Serie sehr neu auf serienstream.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

View File

@ -3,14 +3,12 @@
#ifndef __linux__
#ifndef _WIN32
#error "Error Invalid System: Only for Linux and Windows systems!"
#endif
#endif
#include <iostream>
#include <getopt.h>
#include <string.h> // strlen
@ -27,8 +25,8 @@
#define UpdaterCloudUrlWithPath "https://cloud.obermui.de/s/tXz7SWdaPJ7TacZ/download?path=%2F&files="
#define SecondUpdaterCloudUrlWithPath "https://snew4.obermui.de/download?path=%2F&files="
#define VERSION "5.4.0"
#define DEFAULT_FILE_VERSION "2.4"
#define VERSION "6.0.0"
#define DEFAULT_FILE_VERSION "2.5"
//default, anime, normal,
//suche: für jede katego. eine
@ -64,7 +62,7 @@ struct PAGE {
#include "logger.h"
//Wichtig nach MODUS UND PAGE DECLARATION
//////Wichtig nach MODUS UND PAGE DECLARATION
#include "pageManager.h"
@ -74,16 +72,13 @@ struct Settings {
//erst animes, dann alle seiten-seiten::
const PAGE
_anicio = PAGE( "https://" , "aniworld.to", "Animes", "/animes-alphabet", "/anime/stream/", "/beliebte-animes"),
//alle serien - seiten:
_sto = PAGE( "https://", "s.to", "Normale_Serien", "/serien-alphabet", "/serie/stream/", "/beliebte-serien"),
_stoIP = PAGE( "http://", "190.115.18.20", "Normale_Serien", "/serien-alphabet", "/serie/stream/", "/beliebte-serien"),
serienstreamto = PAGE("https://", "serienstream.to", "Normale_Serien", "/serien-alphabet", "/serie/stream/", "/beliebte-serien"),
seriencam = PAGE("https://", "serien.cam", "Normale_Serien", "/serien-alphabet", "/serie/stream/", "/beliebte-serien");
_stoIP = PAGE( "http://", "186.2.175.5", "Normale_Serien", "/serien-alphabet", "/serie/stream/", "/beliebte-serien"),
serienstreamto = PAGE("https://", "serienstream.to", "Normale_Serien", "/serien-alphabet", "/serie/stream/", "/beliebte-serien");
//alle compakt
const PAGE pagesALL[5] = { _anicio, _sto, _stoIP, /*_serienstreamsx,*/ seriencam, serienstreamto };
const PAGE pagesALL[4] = { _anicio, _sto, _stoIP, /*_serienstreamsx, seriencam, */serienstreamto };
std::vector<PAGE> pagesInUse; // Priority sorted
bool useFirstPage = false;

View File

@ -1833,20 +1833,24 @@ int ProgramManager::searchModus_update(Settings *settings)
}
else if(reply.html.find("</html>") == std::string::npos ) {
std::cout << " => Error: Konnte </html> in searchModus_update() nicht finden." << std::endl;
return 22;
continue;
}
//auf anime seite noic halt auf s.to jetzt anders, näml: data-alternative-title != data-alternative-titles <--s, => data-alternative-title umfasst beides!
std::string serienListe = replace( pageManager.grep( reply.html, "data-alternative-title" ), "</li>", "\n" );
std::string tests[] = {"\" href=\"", "<li><a data-alternative-title", page.UrlDir, "</a>", };
bool cont = false;
for ( auto t : tests ) {
if(reply.html.find( t ) == std::string::npos) {
if(settings->debugMode)
std::cerr << ">>> Debug In " << __FUNCTION__ << ": html doesnt contain:'" << t << "' after preparing." << std::endl;
return 51;
std::cout << " -> Warnung: Überspringe: " << page.name_id << std::endl;
cont = true;;
}
}
if(cont)
continue;
//...\n<li><a data-alternative-title href="/serie /stream/2012-das-jahr-null" title="2012 - Das Jahr Null Stream anschauen">2012 - Das Jahr Null</a>\n...
serienListe = replace(serienListe, "<li><a data-alternative-title", "");

View File

@ -2,8 +2,6 @@
#define MANAGEPROGRAM_H
//#include "pageManager.h"
#include "parameterManager.h"
//#include "accountManager.h"