Esempio n. 1
0
        private void downloadInternal(string url, string path, string filename, MultiDownloader multiDownloader)
        {
            p = new LixProcess();

            p.StartInfo.Arguments =
                " -d \"" + path + "\"" +
                (string.IsNullOrEmpty(filename) ? "" : " -o \"" + filename + "\"") +
                " -c" +
                //" --enable-rpc=true" +
                " --file-allocation=none" +
                //" -j" + Download_Connections +
                " -x" + multiDownloader.Download_Connections +
                " -s" + multiDownloader.Download_Connections +
                " -k10M" +
                " \"" + url + "\"";
            p.StartInfo.FileName               = "aria2c.exe";
            p.StartInfo.CreateNoWindow         = true;
            p.StartInfo.UseShellExecute        = false;
            p.StartInfo.RedirectStandardOutput = true;
            //p.StartInfo.WindowStyle = ProcessWindowStyle.Minimized;
            p.Start();
            while (!p.StandardOutput.EndOfStream)
            {
                if (multiDownloader.IsStopped)
                {
                    SeriesLoader.KillProcessAndChildrens(p.Id);
                    break;
                }
                try
                {
                    var ps = p.StandardOutput.ReadLine();
                    if (!string.IsNullOrWhiteSpace(ps))
                    {
                        ps = ps.Trim();
                        int.TryParse(ps.GetBetweenN("(", "%)"), out int perc);

                        CurrentSize = (long)convert(ps.GetBetweenN(" ", "/"));
                        FullSize    = (long)convert(ps.GetBetweenN("/", "("));
                        Speed       = (long)convert(ps.GetBetween("DL", " "));

                        if (perc > 0)
                        {
                            Percentage = perc;
                        }
                        if (!ps.StartsWith("-"))
                        {
                            DownloadInfo = (ps.Contains("#") ? ("[" + ps.Substring(ps.IndexOf(" ", ps.IndexOf("#")) + 1)) : ps);
                        }
                    }
                }
                catch (Exception x)
                {
                }
            }
        }
Esempio n. 2
0
 public void Stop()
 {
     if (IsSuccess)
     {
         IsFinished = true;
     }
     IsRunning = false;
     if (p != null)
     {
         SeriesLoader.KillProcessAndChildrens(p.Id);
     }
 }