diff --git a/src/parameterManager.cpp b/src/parameterManager.cpp index 3256805..2a68d3c 100644 --- a/src/parameterManager.cpp +++ b/src/parameterManager.cpp @@ -90,7 +90,7 @@ int manageParameter(Settings &settings, int argc, char **argv) //Find out right subProgramm - std::vector res = compare("help\n--help\ndefault\nurl\n--version\nsearch\ninfo\nclean\nnews\n--update\n--remove\nlog", argv[1]); + std::vector res = compare("help\n--help\ndefault\nurl\n--version\nsearch\ninfo\nclean\nnews\n--update\n--remove\nlog\nprintjdscript", argv[1]); if(res.size() != 1) { if(res.size() == 0) std::cout << " => Error: Keine Unteroption für " << argv[1] << " gefunden." << std::endl; @@ -145,6 +145,9 @@ int manageParameter(Settings &settings, int argc, char **argv) logger.logCommandLine(command); return -1; + } else if (isSame(argv, "printjdscript")) { + return unterOption_printJD2_renameSkript(&settings,argc, argv); + } else { std::cout << " => Error: Invalid option '" << argv[1] << "', but not detected in compare-Function" << std::endl; return 3; @@ -1854,3 +1857,44 @@ int setUpInternetPages(Settings &settings, std::string optarg) } return 0; } + +int unterOption_printJD2_renameSkript(Settings *settings, int , char **) +{ + std::cout << "// Settings" << std::endl + << "var FilePath = \"" << settings->logFilePath << "\";" << std::endl + << "var ReplaceWholeName = false;" << std::endl + << "var Delimeter = \"_\"; // S01E01 + Delimeter + Oldname.mp4" << std::endl + << "" << std::endl + << "//Global Vars" << std::endl + << "var LinkFile = readFile(FilePath); // *Read a text file" << std::endl + << "var LinkFileLineArray = LinkFile.split('\n');" << std::endl + << "var myDownloadLink = getAllDownloadLinks(); // *Get a list of all downloadlinks" << std::endl + << "" << std::endl + << "" << std::endl + << "for (var i = 0; i < myDownloadLink.length; i++) {" << std::endl + << "" << std::endl + << " var url = myDownloadLink[i].getUrl();" << std::endl + << " var EpisodeName = myDownloadLink[i].getName();" << std::endl + << " var foundLine = true;" << std::endl + << " var LineWithEp = "";" << std::endl + << "" << std::endl + << " if (EpisodeName.indexOf(\".mp4\") == -1) continue;" << std::endl + << "" << std::endl + << " for (var x = LinkFileLineArray.length - 1; x >= 0; x--)" << std::endl + << " if (LinkFileLineArray[x].indexOf(url) !== -1) {" << std::endl + << " LineWithEp = LinkFileLineArray[x];" << std::endl + << " break;" << std::endl + << " } else if (x == 0) {" << std::endl + << " //alert(\"Error: Für den Link '\" + url + \"' wurde in dem TextFile: '\" + FilePath + \"' keine Passende Zeile gefunden.\");" << std::endl + << " foundLine = false;" << std::endl + << " }" << std::endl + << " if (!foundLine) continue;" << std::endl + << "" << std::endl + << " var addPart = LineWithEp.substring(0, LineWithEp.indexOf(\":\"));" << std::endl + << " if (EpisodeName.indexOf(addPart) !== -1) continue;" << std::endl + << " if (ReplaceWholeName) myDownloadLink[i].setName(addPart + EpisodeName.substring(EpisodeName.lastIndexOf(\".\")));" << std::endl + << " else myDownloadLink[i].setName(addPart + Delimeter + EpisodeName)" << std::endl + << "" << std::endl + << "}" << std::endl; + return 0; +} diff --git a/src/parameterManager.h b/src/parameterManager.h index 39223b0..99dc4e8 100644 --- a/src/parameterManager.h +++ b/src/parameterManager.h @@ -243,6 +243,9 @@ void unterOption_info_help(std::string programName); void unterOption_clean(Settings * settings, int argc, char **argv); +int unterOption_printJD2_renameSkript(Settings * settings, int, char **); + + int unterOption_news(Settings * settings, int argc, char **argv); void unterOption_news_help(std::string programName);