public static void Main(string[] args) { try { ConfigTools.InitConf("Config.xml"); ConfigTools.InitConf("Config_user.xml"); ConfigTools.InitLightNovels("LightNovels.xml", true); ConfigTools.InitLightNovels("LightNovels_user.xml", true); consoleTools = new ConsoleTools(1); ConsoleTools ctForWebcrawler = new ConsoleTools(3); webCrawler = new WebCrawler(ctForWebcrawler, ctForWebcrawler); } catch (ApplicationException e) { consoleTools.Log(e.Message); return; } if (!consoleTools.Ask(String.Format(LightNovelSniffer_CLI_Strings.AskOutputFolderConfirmation, Globale.OUTPUT_FOLDER))) { string folder = consoleTools.AskInformation(LightNovelSniffer_CLI_Strings.AskOutputFolder); if (!string.IsNullOrEmpty(folder)) { Globale.OUTPUT_FOLDER = folder; } } consoleTools.Log(LightNovelSniffer_CLI_Strings.LogProgramStart); foreach (LnParameters ln in Globale.LN_TO_RETRIEVE) { if (consoleTools.Ask(string.Format(LightNovelSniffer_CLI_Strings.AskRetrieveLn, ln.name))) { GetNovel(ln); } } if (Globale.INTERACTIVE_MODE && consoleTools.AskNegative(LightNovelSniffer_CLI_Strings.LogEndOfLnInConfig)) { LnParameters ln; do { ln = BuildDynamicLn(); GetNovel(ln); } while (!string.IsNullOrEmpty(ln.name)); } consoleTools.Log(LightNovelSniffer_CLI_Strings.LogProgramEnd); if (Globale.INTERACTIVE_MODE) { Console.ReadLine(); } }
private static LnParameters BuildDynamicLn() { LnParameters ln = new LnParameters(); ln.name = consoleTools.AskInformation(LightNovelSniffer_CLI_Strings.AskLnName_EmptyToStop); if (string.IsNullOrEmpty(ln.name)) { return(ln); } ln.urlCover = consoleTools.AskInformation(LightNovelSniffer_CLI_Strings.AskCoverUrl); string authors = consoleTools.AskInformation(LightNovelSniffer_CLI_Strings.AskCsvAuthor); if (!string.IsNullOrEmpty(authors)) { foreach (string author in authors.Split(',')) { ln.authors.Add(author.Trim()); } } do { UrlParameter up = new UrlParameter(); up.language = consoleTools.AskInformation(LightNovelSniffer_CLI_Strings.AskLnVersionLanguage); up.url = consoleTools.AskInformation(LightNovelSniffer_CLI_Strings.AskLnVersionChapterUrl); int.TryParse(consoleTools.AskInformation(LightNovelSniffer_CLI_Strings.AskFirstChapterNumber), out up.firstChapterNumber); int.TryParse(consoleTools.AskInformation(LightNovelSniffer_CLI_Strings.AskLastChapterNumber), out up.lastChapterNumber); if (!string.IsNullOrEmpty(up.language) && !string.IsNullOrEmpty(up.url)) { ln.urlParameters.Add(up); } else { consoleTools.Log(LightNovelSniffer_CLI_Strings.LogNoUrlOrLanguageForThisVersion); } } while (consoleTools.Ask(LightNovelSniffer_CLI_Strings.AskAddAnotherLnVersion)); return(ln); }
public static void Main(string[] args) { fileStream = new FileStream("log.txt", FileMode.Create, FileAccess.Write); fileWriter = new FileWriter(fileStream); try { ConfigTools.InitConf("Config.xml"); ConfigTools.InitConf("Config_user.xml"); ConfigTools.InitLightNovels("LightNovels.xml", true); ConfigTools.InitLightNovels("LightNovels_user.xml", true); consoleTools = new ConsoleTools(fileWriter, 1); ConsoleTools ctForCore = new ConsoleTools(fileWriter, 3); lightNovelSniffer = new LNS(ctForCore, ctForCore); } catch (ApplicationException e) { consoleTools.Log(e.Message); return; } ShowBannier(); consoleTools.Log(LightNovelSniffer_CLI_Strings.LogProgramStart); if (!consoleTools.Ask(String.Format(LightNovelSniffer_CLI_Strings.AskOutputFolderConfirmation, Globale.OUTPUT_FOLDER))) { string folder = consoleTools.AskInformation(LightNovelSniffer_CLI_Strings.AskOutputFolder); if (!string.IsNullOrEmpty(folder)) { Globale.OUTPUT_FOLDER = folder; } } foreach (LnParameters ln in Globale.LN_TO_RETRIEVE) { if (consoleTools.Ask(string.Format(LightNovelSniffer_CLI_Strings.AskRetrieveLn, ln.name))) { GetNovel(ln); } } if (Globale.INTERACTIVE_MODE && consoleTools.AskNegative(LightNovelSniffer_CLI_Strings.LogEndOfLnInConfig)) { LnParameters ln; do { ln = BuildDynamicLn(); GetNovel(ln); } while (!string.IsNullOrEmpty(ln.name)); } consoleTools.Log(LightNovelSniffer_CLI_Strings.LogProgramEnd); fileWriter.Close(); fileStream.Close(); if (Globale.INTERACTIVE_MODE) { Console.ReadLine(); } }