v4.0.3: language & hoster : ignore low/upper writing + move replace vivo things in getLinkAfterHosterBasedOperation() Funktion

This commit is contained in:
Markus 2020-04-06 14:31:34 +02:00
parent b2a9fabba6
commit a4e86c3250
5 changed files with 78 additions and 11 deletions

View File

@ -0,0 +1,22 @@
#include "programManager.h"

int main(int argc, char *argv[])
{

std::cout << "test: ,.12-.*'§ und: " << PageManager::upper_string("abced<<,.12-.*'§") << std::endl;

return 0;

ProgramManager mainProgram;
Settings settings;
int res = manageParameter(settings, argc, argv);
if(res == -1)
return 0;
else if(res != 0) {
if(settings.debugMode)
std::cout << " => Error: Das Auswerten der Parameter ist fehlgeschlagen!" << std::endl;
return res;
} else {
return mainProgram.start(&settings);
}
}

View File

@ -471,11 +471,11 @@ std::string PageManager::chooseHosterLink(std::string HosterList, std::string Ho


if(langId == "") if(langId == "")
continue; continue;
else if ( langId == "GerDub" ) else if ( upper_string( langId ) == "GERDUB" )
LangId=1; LangId=1;
else if ( langId == "Eng" ) else if ( upper_string( langId ) == "ENG" )
LangId=2; LangId=2;
else if ( langId == "GerSub" ) else if ( upper_string( langId ) == "GERSUB" )
LangId=3; LangId=3;
else { else {
std::cout << " => Error: Unbekannte Sprache: " << langId << std::endl; std::cout << " => Error: Unbekannte Sprache: " << langId << std::endl;
@ -493,15 +493,25 @@ std::string PageManager::chooseHosterLink(std::string HosterList, std::string Ho
continue; continue;
} }


//Upper all Hoster Name in List:
for (size_t posHoster = LanguageSortedHoster.find("hoster=\""); posHoster != std::string::npos; posHoster = LanguageSortedHoster.find("hoster=\"", posHoster + 8)) {
size_t posNextAnfz = LanguageSortedHoster.find("\"", posHoster + 8);
if(posNextAnfz == std::string::npos) {
std::cout << " => Error: Konnte \" in chooseHosterLink() nicht finden." << std::endl;
break;
} else
LanguageSortedHoster.replace(posHoster + 8, posNextAnfz - posHoster - 8, upper_string(LanguageSortedHoster.substr(posHoster + 8, posNextAnfz - posHoster - 8)) );
}

//Für jeden Angegebenen Hoster: //Für jeden Angegebenen Hoster:
while (getline(SListHoster, hoster).good()) { while (getline(SListHoster, hoster).good()) {
//Wenn es den hoster bei dieser prache nicht gibt, wähle nächsten //Wenn es den hoster bei dieser prache nicht gibt, wähle nächsten
if(LanguageSortedHoster.find("hoster=\"" + hoster + "\"") == std::string::npos) { if(LanguageSortedHoster.find( "hoster=\"" + upper_string(hoster) + "\"" ) == std::string::npos) {
if(withWarnMsg) if(withWarnMsg)
std::cout << "Warnung: Hoster " << hoster << " gibt es bei der sprache" << langId << " nicht " << std::endl; std::cout << "Warnung: Hoster " << hoster << " gibt es bei der sprache" << langId << " nicht " << std::endl;
continue; continue;
} }
Line = grep(LanguageSortedHoster + "\n", ("hoster=\"" + hoster + "\"" ) ); Line = grep(LanguageSortedHoster + "\n", ("hoster=\"" + upper_string(hoster) + "\"" ) );
pos = Line.find("href=\""); pos = Line.find("href=\"");
if(pos == std::string::npos) { if(pos == std::string::npos) {
std::cout << " => Error: Konnte 'href=\"' in chooseHosterLink() nicht finden." << std::endl; std::cout << " => Error: Konnte 'href=\"' in chooseHosterLink() nicht finden." << std::endl;
@ -526,3 +536,31 @@ std::string PageManager::chooseHosterLink(std::string HosterList, std::string Ho
} }
return ""; return "";
} }

std::string PageManager::getLinkAfterHosterBasedOperation(std::string url)
{
size_t pos1 = 0, pos2 = 0;
if(debugMode)
std::cout << "Convert url: " << url << " ->"<< std::endl;

if((pos1 = url.find("://")) == std::string::npos) {
std::cout << " => Error: Konnte '://' in getLinkAfterHosterBasedOperation() nicht finden." << std::endl;
return "";
} else if((pos2 = url.find(".", pos1 + 3)) == std::string::npos) {
std::cout << " => Error: Konnte '.' nach '://' in getLinkAfterHosterBasedOperation() nicht finden." << std::endl;
return "";
}

std::string hoster = url.substr(pos1 + 3, pos2 - pos1 - 3);
if(hoster == "vivo") {
url = replace(url, "/embed/", "/");
url = replace(url, "http://", "https://");

} else if (hoster == "...") {

}

if(debugMode)
std::cout << " -> zu... " << url << std::endl;
return url;
}

View File

@ -38,10 +38,11 @@ public:
std::string checkName(std::string Name); std::string checkName(std::string Name);
std::string getLinks(std::string HTML); std::string getLinks(std::string HTML);
std::string chooseHosterLink(std::string HosterList, std::string Hoster_with_Highst_Priority_at_First, std::string languages_with_highst_priority_at_first, bool withWarnMsg); std::string chooseHosterLink(std::string HosterList, std::string Hoster_with_Highst_Priority_at_First, std::string languages_with_highst_priority_at_first, bool withWarnMsg);
std::string getLinkAfterHosterBasedOperation(std::string url);


int counterContains(std::string text, std::string substring_with_prozent_i_for_number, int starte_mit_dieser_Zahl = 1); 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 grep(std::string text, std::string substring, bool IgnoreCaseSensetifity = false);
std::string upper_string(const std::string& str); static std::string upper_string(const std::string& str);
size_t getDate(); size_t getDate();
std::string getExePath(); std::string getExePath();



View File

@ -91,7 +91,7 @@ struct Settings {
proxy_ip = "127.0.0.1", proxy_ip = "127.0.0.1",
languages = "GerDub,GerSub,Eng,", languages = "GerDub,GerSub,Eng,",
genaueHoster = "", genaueHoster = "",
version = "4.0.2", version = "4.0.3",
defaultFileVersion="1.8", defaultFileVersion="1.8",
default_checkPath = "", default_checkPath = "",
default_Searchmuster = "S%Staffel%E%Folge%"; default_Searchmuster = "S%Staffel%E%Folge%";

View File

@ -130,8 +130,11 @@ void * threadFunction(void * data) {


// get NO-Redirect Link after getUrlAfterRedirect Function // get NO-Redirect Link after getUrlAfterRedirect Function
} else { } else {
// für Vivo... if( (newUrl = myThreadData->pageManager->getLinkAfterHosterBasedOperation(newUrl)) == "") {
newUrl = replace(newUrl, "/embed/", "/"); if(myThreadData->settings->debugMode)
std::cout << " => Error in getLinkAfterHosterBasedOperation() -> exit threadFunction()" << std::endl;
return myThreadData->setState(22);
}


myThreadData->returnValue = " => " + folgenID + ( (folgenID == "") ? "" : ": " ) + green + newUrl + clearColor; myThreadData->returnValue = " => " + folgenID + ( (folgenID == "") ? "" : ": " ) + green + newUrl + clearColor;
if(myThreadData->settings->outputFilePaths.size() != 0) { if(myThreadData->settings->outputFilePaths.size() != 0) {
@ -1540,8 +1543,11 @@ int ProgramManager::convertLink(std::string redirectLink, AccountManager * accou
return 0; return 0;
//sonst war die umwandlung erfolgreich //sonst war die umwandlung erfolgreich
} else { } else {
// für Vivo... if( (newUrl = pageManager.getLinkAfterHosterBasedOperation(newUrl)) == "") {
newUrl = replace(newUrl, "/embed/", "/"); if(settings->debugMode)
std::cout << " => Error in getLinkAfterHosterBasedOperation() -> exit convertLink()" << std::endl;
return 118;
}


std::cout << " => " << folgenID << ( (folgenID == "") ? "" : ": " ) << green << newUrl << ((settings->colorless) ? "" : "\033[0m") << std::endl; std::cout << " => " << folgenID << ( (folgenID == "") ? "" : ": " ) << green << newUrl << ((settings->colorless) ? "" : "\033[0m") << std::endl;
if(settings->outputFilePaths.size() != 0) if(settings->outputFilePaths.size() != 0)