コード例 #1
0
 private static void WarningText(string updateTarget)
 {
     AlLite.WriteLine(WriteMode.WARN, $" :: If you have entered a {updateTarget.ToLower()} as a command line argument, ");
     AlLite.WriteLine(WriteMode.WARN, $" :: it is recommended that you clear your command history in any case.");
     AlLite.WriteLine(WriteMode.WARN, $" :: => history -d <history_num> OR history -c");
     AlLite.WriteLine(WriteMode.WARN, $" ::   <history_num> - If you run history with no arguments, you will see a numbered command history.");
 }
コード例 #2
0
        public static void Decomposition(string[] targetArgs)
        {
            if (targetArgs.Length < 1)
            {
                AlLite.WriteLine(WriteMode.CAUT, "Skipped config generate.");
                Settings.DoSkipConfigGenerate = true;
                return;
            }
            try {
                for (int i = 0; i < targetArgs.Length; i++)
                {
                    switch (targetArgs[i])
                    {
                    case "--user":
                        Settings.DataBaseUserName = targetArgs[++i];
                        break;

                    case "--pass":
                        Settings.DataBasePassWord = targetArgs[++i];
                        break;
                    }
                }
            } catch (IndexOutOfRangeException) {
                AlLite.WriteLine(WriteMode.ERR, "Incorrect Number of Arguments.");
            }
        }
コード例 #3
0
 private static string updateDbUserName(ConfigModel targetModel, [Optional] string dbUserName)
 {
     if (dbUserName == null)
     {
         AlLite.WriteLine(WriteMode.INFO, "No Update DataBase UserName."); return(targetModel.DB_ACCESS_USERNAME);
     }
     AlLite.WriteLine(WriteMode.INFO, $"Update DataBase UserName: {dbUserName}");
     return(dbUserName);
 }
コード例 #4
0
 private static string updateDbPassWord(ConfigModel targetModel, [Optional] string dbPassWord)
 {
     if (dbPassWord == null)
     {
         AlLite.WriteLine(WriteMode.INFO, "No Update DataBase PassWord."); return(targetModel.DB_ACCESS_PASSWORD);
     }
     AlLite.WriteLine(WriteMode.INFO, $"Update DataBase PassWord: {Encrypter.onEncrypt(dbPassWord)}");
     WarningText("Password");
     return(dbPassWord);
 }
コード例 #5
0
 private static string updateApiKey(ConfigModel targetModel, [Optional] string apiKey)
 {
     if (apiKey == null)
     {
         AlLite.WriteLine(WriteMode.INFO, "No Update ApiKey."); return(targetModel.API_KEY);
     }
     AlLite.WriteLine(WriteMode.INFO, $"Update ApiKey: {apiKey.Substring(0, 3)}");
     WarningText("apiKey");
     return(apiKey);
 }
コード例 #6
0
        private static List <IgnoreData> updateIgnoreData(ConfigModel targetModel, List <IgnoreData> ignoreData)
        {
            if (ignoreData.Count <= 0)
            {
                AlLite.WriteLine(WriteMode.INFO, "No Update Ignore Data."); return(targetModel.ignoreData);
            }
            ignoreData.ForEach(data => targetModel.ignoreData.Add(data));
            List <IgnoreData> update = targetModel.ignoreData;

            AlLite.WriteLine(WriteMode.INFO, $"Update Ignore Data: {ignoreData.Count} updates");
            return(update);
        }
コード例 #7
0
        public static void Decomposition(string[] arg)
        {
            ConfigModel model = ConfigImporter.onDeserialize(false);

            try {
                for (int i = 0; i < arg.Length; i++)
                {
                    switch (arg[i])
                    {
                    case "--clear":
                        ConfigExporter.onTemplateGenerate();
                        break;

                    case "-a":
                    case "--api-key":
                        apiKey = arg[++i];
                        break;

                    case "-u":
                    case "--user":
                        userName = arg[++i];
                        break;

                    case "-p":
                    case "--pass":
                        passWord = arg[++i];
                        break;

                    case "-ia":
                    case "--ignore-add":
                        ignoreData.Add(CheckRequest.onCheck(model, arg[++i]));
                        break;

                    case "-iaa":
                    case "--ignore-add-array":
                        arg[++i].Split(',').ToList().ForEach(videoId => {
                            ignoreData.Add(CheckRequest.onCheck(model, videoId));
                        });
                        break;
                    }
                }
            } catch (IndexOutOfRangeException) {
                AlLite.WriteLine(WriteMode.ERR, "Incorrect Number of Arguments.");
            }

            ConfigUpdater.onUpdate(apiKey, userName, passWord, ignoreData);
        }
コード例 #8
0
        public static ConfigModel.IgnoreData onCheck(ConfigModel model, string ignoreVideoId)
        {
            HttpClient  httpClient = new HttpClient();
            ParseObject parseObject;

            try {
                AlLite.WriteLine(WriteMode.INFO, $"Checking :: {ignoreVideoId}");
                string getObj = httpClient.GetStringAsync(
                    $"https://www.googleapis.com/youtube/v3/videos?" +
                    $"id={ignoreVideoId}&key={model.API_KEY}&" +
                    $"fields=items(id,snippet/title)&part=snippet").Result;
                parseObject = JsonConvert.DeserializeObject <ParseObject>(getObj);
            } catch (Exception e) {
                Console.WriteLine(e);
                throw;
            }
            return(new ConfigModel.IgnoreData()
            {
                IgnoreDataName = parseObject.items[0].snippet.title, IgnoreVideoId = ignoreVideoId
            });
        }