Пример #1
0
        public void PromptParameters()
        {
            UI.Log("");
            UI.Log("    . . . . . . . . . . . . . . . .  .  ");
            UI.Log("               Methane                  ");
            UI.Log("            Bulk HTTP Download          ");
            UI.Log("    . . . . . . . . . . . . . . . .  .  ");
            UI.Log("");


ChooseCookies:
            Cookie = UI.Prompt("Enter cookies to use OR Enter ~filename to read cookies OR [Enter] not to use cookies");

            HasCookie = Cookie.Length > 0;
            if (Cookie.StartsWith('~'))
            {
                if (Cookie == "~")
                {
                    Cookie = "~cookie.txt";
                }
                try
                {
                    Cookie = File.ReadAllText(Cookie.TrimStart('~'));
                }
                catch (Exception ex)
                {
                    UI.LogError(ex);
                    goto ChooseCookies;
                }
            }


ChooseHeaders:
            Headers = UI.Prompt("Enter Headers to use OR Enter ~filename to read Headers OR [Enter] not to use Headers");

            HasHeaders = Headers.Length != 0;
            if (Headers.StartsWith('~'))
            {
                if (Headers == "~")
                {
                    Headers = "~headers.txt";
                }
                try
                {
                    Headers = File.ReadAllText(Headers.TrimStart('~'));
                }
                catch (Exception ex)
                {
                    UI.LogError(ex);
                    goto ChooseHeaders;
                }
            }


ChooseSavePath:

            SavePath = UI.Prompt("Enter path to save files or ~ to use  \"Downloaded/\" ");
            if (SavePath == "~")
            {
                SavePath = "Downloaded/";
            }

            try
            {
                if (!string.IsNullOrEmpty(SavePath))
                {
                    Directory.CreateDirectory(SavePath);
                    if (!SavePath.EndsWith('/'))
                    {
                        SavePath += '/';
                    }
                }
            }
            catch (Exception ex)
            {
                UI.LogError(ex);
                goto ChooseSavePath;
            }



            if (csa == null)
            {
                UI.Log("Please use the following tool to create download url list. \n"
                       + " File name suffixes can be inserted at the end of urls inside { }   Ex: http://example.com/file.zip{ABC}\n"
                       + "These downloaded files will be named like fileABC.zip   (Tip : use pipelines for suffixes) \n");
                csa = UI.Lab?.Request <CSA>();
                if (csa == null)
                {
                    csa = new CSA(UI);
                    csa.PromptParameters();
                }
            }

            // ChooseReqOrder:
            if (!DontAskRequireOrderLog)
            {
                if (UI.Prompt("Do you want a downloaded-order.txt file ? [y/N]").ToLower().Trim() == "y")
                {
                    RequireOrderLog = true;
                }
                else
                {
                    RequireOrderLog = false;
                }
            }

PromptHowManyThreads:
            if (!int.TryParse(UI.Prompt("How many threads to use?"), out AllowedThrds))
            {
                goto PromptHowManyThreads;
            }

PromptRetryCount:
            if (int.TryParse(UI.Prompt("If failed on network issue, How many times to retry?"), out int retries))
            {
                RetryCount = retries;
            }
            else
            {
                goto PromptRetryCount;
            }

            UI.Log("Rapid Downloader standby    :-) ");
        }