v3.4.7: add option -o at subfunktion info

This commit is contained in:
Markus 2019-11-23 22:06:57 +01:00
parent b4310cbf13
commit 2be77bd2ca
3 changed files with 73 additions and 8 deletions

View File

@ -606,8 +606,8 @@ void unterOption_default_help(std::string programName)
<< " Standart: 127.0.0.1:9050 - Port 0 um Proxy zu deaktivieren." << std::endl << std::endl << " Standart: 127.0.0.1:9050 - Port 0 um Proxy zu deaktivieren." << std::endl << std::endl
<< "AUSGABEOPTIONEN:" << std::endl << "AUSGABEOPTIONEN:" << std::endl
<< " -o [Pfad], --output-file [Pfad]" << std::endl << " -o [Pfad], --output-file [Pfad]" << std::endl
<< " Mit diere Option kann man ein (nichtvorhandenes) Text-Datei" << std::endl << " Mit diere Option kann man eine (nichtvorhandene) Text-Datei" << std::endl
<< " angeben, inwelches die umgewandelten Redirect-Links geschrieben" << std::endl << " angeben, inwelche die umgewandelten Redirect-Links geschrieben" << std::endl
<< " werden. Beachte: Wenn die Datei von -C existiert, dann" << std::endl << " werden. Beachte: Wenn die Datei von -C existiert, dann" << std::endl
<< " schreibt das Programm kein 'Name: ...' in die Datei." << std::endl << " schreibt das Programm kein 'Name: ...' in die Datei." << std::endl
<< " -c, --colorless" << std::endl << " -c, --colorless" << std::endl
@ -881,6 +881,7 @@ int unterOption_info(Settings *settings, int argc, char **argv)
int c = 0; int c = 0;
const option long_opts[] = { const option long_opts[] = {
{"socks5-proxy", required_argument, nullptr, 'p'}, {"socks5-proxy", required_argument, nullptr, 'p'},
{"output-file", required_argument, nullptr, 'o'},


{"help", no_argument, nullptr, 'h'}, {"help", no_argument, nullptr, 'h'},
{"colorless", no_argument, nullptr, 'c'}, {"colorless", no_argument, nullptr, 'c'},
@ -891,12 +892,18 @@ int unterOption_info(Settings *settings, int argc, char **argv)


}; };


while( ( c = getopt_long (argc, argv, "p:hcds", long_opts, nullptr) ) != -1 ) { while( ( c = getopt_long (argc, argv, "p:o:hcds", long_opts, nullptr) ) != -1 ) {
switch(c) { switch(c) {
case 'p': case 'p':
if(!optarg || setS5ProxytoSettings(*settings, optarg) != 0) if(!optarg || setS5ProxytoSettings(*settings, optarg) != 0)
return 2; return 2;
break; break;
case 'o':
if(optarg)
settings->outputFilePath = optarg;
if(settings->debugMode)
std::cout << "Pfad zu Output-Datei: " << settings->outputFilePath << std::endl;
break;
case 'h': case 'h':
unterOption_info_help(settings->programName); unterOption_info_help(settings->programName);
return -1; return -1;
@ -958,6 +965,9 @@ void unterOption_info_help(std::string programName)
<< " -s, --skip-episoden-names" << std::endl << " -s, --skip-episoden-names" << std::endl
<< " Mit dieser Option kann man die Ausgabe der Namen der" << std::endl << " Mit dieser Option kann man die Ausgabe der Namen der" << std::endl
<< " einzelnen Folgen ausschalten." << std::endl << std::endl << " einzelnen Folgen ausschalten." << std::endl << std::endl
<< " -o [Pfad], --output-file [Pfad]" << std::endl
<< " Mit diere Option kann man eine (nichtvorhandene) Text-Datei" << std::endl
<< " angeben, inwelche die Infos geschrieben werden." << std::endl
<< " -h, --help" << std::endl << " -h, --help" << std::endl
<< " Mit dieser Option wird dieses Helpmenue ausgegeben." << std::endl; << " Mit dieser Option wird dieses Helpmenue ausgegeben." << std::endl;
} }

View File

@ -81,7 +81,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 = "3.7.3", version = "3.7.4",
defaultFileVersion="1.7", defaultFileVersion="1.7",
outputFilePath = "", outputFilePath = "",
default_checkPath = "", default_checkPath = "",

View File

@ -761,6 +761,15 @@ int ProgramManager::infoModus(Settings *settings)
} }
} }


//write Name to file
if(pageManager.writeToFile(settings->outputFilePath, "\n\nSerie: " + settings->name + " (" + nameInUrl + ")") != 0)
{
if(settings->debugMode)
std::cerr << ">>> Debug In " << __FUNCTION__ << ": writeToFile f() failed." << std::endl;
return 100;
}


//Finde Anzahl der Staffel heraus: //Finde Anzahl der Staffel heraus:
Reply tmp_reply = pageManager.getServerRequest(pageManager.UrlPraefix + nameInUrl); Reply tmp_reply = pageManager.getServerRequest(pageManager.UrlPraefix + nameInUrl);
if(tmp_reply.html == "-1") { if(tmp_reply.html == "-1") {
@ -793,9 +802,18 @@ int ProgramManager::infoModus(Settings *settings)
return 40; return 40;
} }


int folgen = pageManager.counterContains(tmpReply.html, "/episode-%i");
std::cout << std::endl std::cout << std::endl
<< green << "Die Staffel " << staffel << " hat " << pageManager.counterContains(tmpReply.html, "/episode-%i") << " Folge(n)." << white << std::endl << green << "Die Staffel " << staffel << " hat " << folgen << " Folge" << ((folgen > 1) ? "n" : "") << "." << white << std::endl
<< std::endl; << std::endl;
if(pageManager.writeToFile(settings->outputFilePath, "\nDie Staffel " + std::to_string(staffel)
+ " hat " + std::to_string(folgen) + " Folge" + ((folgen > 1) ? "n" : "") + ".\n") != 0)
{
if(settings->debugMode)
std::cerr << ">>> Debug In " << __FUNCTION__ << ": writeToFile f() failed." << std::endl;
return 110;
}



std::string html = tmpReply.html; std::string html = tmpReply.html;
size_t pos = 0; size_t pos = 0;
@ -833,6 +851,14 @@ int ProgramManager::infoModus(Settings *settings)
<< " ( " << blue << "S" << ( (staffel < 10) ? "0" : "" ) << staffel << " ( " << blue << "S" << ( (staffel < 10) ? "0" : "" ) << staffel
<< "E" << ( ( atoi( line.substr(0, pos).c_str() ) < 10) ? "0" : "" ) << line.substr(0, pos) << lila << " ):" << white <<std::endl; << "E" << ( ( atoi( line.substr(0, pos).c_str() ) < 10) ? "0" : "" ) << line.substr(0, pos) << lila << " ):" << white <<std::endl;


if(pageManager.writeToFile(settings->outputFilePath, "Ep. " + std::string( (gesammtFolge < 100) ? ( (gesammtFolge < 10) ? "00" : "0" ) : "" )
+ std::to_string(gesammtFolge) + " ( S" + ( (staffel < 10) ? "0" : "" ) + std::to_string(staffel) + "E"
+ ( ( atoi( line.substr(0, pos).c_str() ) < 10) ? "0" : "" ) + line.substr(0, pos) + " ):" ) != 0) {
if(settings->debugMode)
std::cerr << ">>> Debug In " << __FUNCTION__ << ": writeToFile f() failed." << std::endl;
return 105;
}

if( (pos = line.find("<strong>")) == std::string::npos) { if( (pos = line.find("<strong>")) == std::string::npos) {
std::cout << " => Error: Konnte Position von '<strong>' nicht finden." << std::endl; std::cout << " => Error: Konnte Position von '<strong>' nicht finden." << std::endl;
return 43; return 43;
@ -843,8 +869,14 @@ int ProgramManager::infoModus(Settings *settings)
return 44; return 44;
} }
titel = line.substr(0, pos); titel = line.substr(0, pos);
if(titel != "") if(titel != "") {
std::cout << lila << " > Titel 1: " << Lightyellow << titel << white << std::endl; std::cout << lila << " > Titel 1: " << Lightyellow << titel << white << std::endl;
if(pageManager.writeToFile(settings->outputFilePath, " > Titel 1: " + titel) != 0) {
if(settings->debugMode)
std::cerr << ">>> Debug In " << __FUNCTION__ << ": writeToFile f() failed." << std::endl;
return 110;
}
}


if( (pos = line.find("<span>")) == std::string::npos) { if( (pos = line.find("<span>")) == std::string::npos) {
std::cout << " => Error: Konnte Position von '<span>' nicht finden." << std::endl; std::cout << " => Error: Konnte Position von '<span>' nicht finden." << std::endl;
@ -856,8 +888,15 @@ int ProgramManager::infoModus(Settings *settings)
return 44; return 44;
} }
titel = line.substr(0, pos); titel = line.substr(0, pos);
if(titel != "") if(titel != "") {
std::cout << lila << " > Titel 2: " << Darkyellow << titel << white << std::endl; std::cout << lila << " > Titel 2: " << Darkyellow << titel << white << std::endl;
if(pageManager.writeToFile(settings->outputFilePath, " > Titel 2: " + titel) != 0) {
if(settings->debugMode)
std::cerr << ">>> Debug In " << __FUNCTION__ << ": writeToFile f() failed." << std::endl;
return 120;
}

}
} }


} }
@ -951,7 +990,9 @@ int ProgramManager::infoModus(Settings *settings)
std::string coverLink = line.substr(pos + 10, pos2 - pos -10); std::string coverLink = line.substr(pos + 10, pos2 - pos -10);




std::cout << lila << "Produktion von " << blue << startStopDates[0] << lila << " bis " << blue << startStopDates[1] << lila << std::endl //Ausgabe

std::cout << lila << "\nProduktion von " << blue << startStopDates[0] << lila << " bis " << blue << startStopDates[1] << lila << std::endl
<< "FSK: " << blue << fsk << lila << std::endl << "FSK: " << blue << fsk << lila << std::endl
<< "Cover Bild: " << green << coverLink << lila << std::endl << "Cover Bild: " << green << coverLink << lila << std::endl
<< "Genre(s): " << blue << std::flush; << "Genre(s): " << blue << std::flush;
@ -961,6 +1002,20 @@ int ProgramManager::infoModus(Settings *settings)
std::cout << lila << std::endl << "\nBeschreibung: " << green << description << white << std::endl; std::cout << lila << std::endl << "\nBeschreibung: " << green << description << white << std::endl;




//Schreibe das auch in ein Text file:
std::string all_genres;
for( const auto &e : genres)
all_genres += e + " ";

if(pageManager.writeToFile(settings->outputFilePath, "\nProduktion von " + startStopDates[0] + " bis " + startStopDates[1] + "\n"
"FSK: " + fsk + "\n" + "Cover Bild: " + coverLink + "\n" + "Genre(s): " + all_genres + "\n"
"\nBeschreibung: " + description + "\n") != 0)
{
if(settings->debugMode)
std::cerr << ">>> Debug In " << __FUNCTION__ << ": writeToFile f() failed." << std::endl;
return 130;
}

if(settings->debugMode) if(settings->debugMode)
std::cerr << ">>> Debug In " << __FUNCTION__ << ": success exit." << std::endl; std::cerr << ">>> Debug In " << __FUNCTION__ << ": success exit." << std::endl;
return 0; return 0;