fix big errors: 1. in listDir add to subdir in Windows an / ,too not an ; 2.: names with an / in the name: error with search modos etc: function looks for / at url name => now: looks for |/

This commit is contained in:
Markus 2019-10-27 21:34:03 +01:00
parent e79caf03af
commit c4bbb35e11
2 changed files with 10 additions and 8 deletions

View File

@ -59,7 +59,7 @@ Reply PageManager::getServerRequest(std::string Url, bool useCookies, std::strin

//Settings
//curl_easy_setopt(curl, CURLOPT_FAILONERROR, true); // html errors to errorcode res

//curl_easy_setopt(curl, CURLOPT_NOPROGRESS, false); // Progressausgabe aktivieren
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

View File

@ -183,7 +183,7 @@ int ProgramManager::sucheNach_1_Serien(Settings *settings, PageManager &pageMana
return 24;

// Wenn der Rückgabe wert ungültig ist brich ab...
} else if(finds.find("/") == std::string::npos || finds.find("|") == std::string::npos ) { // ||
} else if( finds.find("|/") == std::string::npos ) { // ||
if(settings->debugMode)
std::cerr << ">>> Debug In " << __FUNCTION__ << ": searchModus's returnValue contains no / or | => error " << std::endl;
return 45;
@ -227,7 +227,9 @@ int ProgramManager::sucheNach_1_Serien(Settings *settings, PageManager &pageMana
// Wenn die Zeile gleich der ausgewählten ist:
} else if(static_cast<int>(i) == atoi(input.c_str()) ) {
//Speichere den Namen der Serie und setzte hasName auf true und brich schleife ab
if ( (finds = line.substr( line.find("/") + 1, line.find("|", line.find("/")) - line.find("/") -1) ) == "" ) {
if ( (finds = line.substr( line.find("|/") + 2, // beginn: nach dem |/
line.find("|", line.find("|/") + 2) // Bis zu dem | ab dem ende von |/
- line.find("|/") -2) ) == "" ) { // wegen nicht bi sondern länge, suptrahiere Pos 1
std::cout << " => Error: Konnte den Namen aus der zurückgegebenen Zeile nicht extrahieren. In ausWahlVariante" << std::endl;
if(settings->debugMode)
std::cerr << ">>> Debug In " << __FUNCTION__ << ": Return value from searchModus.subStr(pos(/)-> next |, after /) is ''." << std::endl;
@ -249,7 +251,7 @@ int ProgramManager::sucheNach_1_Serien(Settings *settings, PageManager &pageMana
line = finds;

//Überschreibe eine Zeile mit nur dem url Namen
if ( (finds = finds.substr( finds.find("/") + 1, finds.find("|", finds.find("/")) - finds.find("/") -1) ) == "" ) {
if ( (finds = finds.substr( finds.find("|/") + 2, finds.find("|", finds.find("|/") + 2) - finds.find("|/") -2) ) == "" ) {
std::cout << " => Error: Konnte den Namen aus der zurückgegebenen Zeile nicht extrahieren." << std::endl;
if(settings->debugMode)
std::cerr << ">>> Debug In " << __FUNCTION__ << ": Return value from searchModus.subStr(pos(/)-> next |, after /) is ''." << std::endl;
@ -699,8 +701,8 @@ int ProgramManager::searchModus(Settings *settings, std::string *saveTo, bool no
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) << "]"
std::cout << " > " << line.substr(line.find_last_of('|') + 1, std::string::npos )
<< "\t[" << line.substr(line.find("|/") + 2, line.find("|", line.find("|/") + 2) - line.find("|/") - 2) << "]"
<< ( (line[0] == '|') ? "" : "\t( " + line.substr(0, line.find("|")) + " )" ) << std::endl;
}
if(settings->debugMode)
@ -1302,8 +1304,8 @@ int ProgramManager::listDir(std::string &list,std::string path, int maxDepth)
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 if(dirExists((path + dp->d_name + ((path.find("/") == std::string::npos) ? "\\" : "/") ))) { //if(dp->d_type == DT_DIR) {
listDir(list, (path + dp->d_name + ((path.find("/") == std::string::npos) ? "\\" : "/") ), maxDepth);
} else
list.append( std::string(dp->d_name) + "\n" );
}