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

{"help", no_argument, nullptr, 'h'},
{"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) {
case 'p':
if(!optarg || setS5ProxytoSettings(*settings, optarg) != 0)
return 2;
break;
case 'o':
if(optarg)
settings->outputFilePath = optarg;
if(settings->debugMode)
std::cout << "Pfad zu Output-Datei: " << settings->outputFilePath << std::endl;
break;
case 'h':
unterOption_info_help(settings->programName);
return -1;
@ -958,6 +965,9 @@ void unterOption_info_help(std::string programName)
<< " -s, --skip-episoden-names" << std::endl
<< " Mit dieser Option kann man die Ausgabe der Namen der" << 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
<< " Mit dieser Option wird dieses Helpmenue ausgegeben." << std::endl;
}

View File

@ -81,7 +81,7 @@ struct Settings {
proxy_ip = "127.0.0.1",
languages = "GerDub,GerSub,Eng,",
genaueHoster = "",
version = "3.7.3",
version = "3.7.4",
defaultFileVersion="1.7",
outputFilePath = "",
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:
Reply tmp_reply = pageManager.getServerRequest(pageManager.UrlPraefix + nameInUrl);
if(tmp_reply.html == "-1") {
@ -793,9 +802,18 @@ int ProgramManager::infoModus(Settings *settings)
return 40;
}

int folgen = pageManager.counterContains(tmpReply.html, "/episode-%i");
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;
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;
size_t pos = 0;
@ -833,6 +851,14 @@ int ProgramManager::infoModus(Settings *settings)
<< " ( " << blue << "S" << ( (staffel < 10) ? "0" : "" ) << staffel
<< "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) {
std::cout << " => Error: Konnte Position von '<strong>' nicht finden." << std::endl;
return 43;
@ -843,8 +869,14 @@ int ProgramManager::infoModus(Settings *settings)
return 44;
}
titel = line.substr(0, pos);
if(titel != "")
if(titel != "") {
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) {
std::cout << " => Error: Konnte Position von '<span>' nicht finden." << std::endl;
@ -856,8 +888,15 @@ int ProgramManager::infoModus(Settings *settings)
return 44;
}
titel = line.substr(0, pos);
if(titel != "")
if(titel != "") {
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::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
<< "Cover Bild: " << green << coverLink << lila << std::endl
<< "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;


//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)
std::cerr << ">>> Debug In " << __FUNCTION__ << ": success exit." << std::endl;
return 0;