Exemple #1
0
        public Downloader(BeatmapsetPackage p, FileWriter fileWriter = null)
        {
            if (fileWriter != null)
            {
                this.FileWriter = fileWriter;
            }
            else
            {
                this.FileWriter = FileHelper.FileWrite;
            }

            BeatmapsetPackage = p;
        }
Exemple #2
0
        private void Downloader_DoWork(object sender, DoWorkEventArgs e)
        {
            DownloadEngine.Downloader downloader        = new Downloader();
            BeatmapsetPackage         beatmapsetPackage = new BeatmapsetPackage(new Beatmapset(((string)e.Argument)));

            downloader.BeatmapsetPackage = beatmapsetPackage;

            DownloadPackage downloadPackage = new DownloadPackage(beatmapsetPackage.Beatmapset);

            packageCollection.Add(downloadPackage);
            beatmapsetPackage.ProgressChanged += delegate(object o, ProgressChangedEventArgs args)
            {
                downloadPackage.ProgressPercentage = args.ProgressPercentage;
            };
            beatmapsetPackage.WriteFileCompleted += delegate(object o, BeatmapsetPackage.WriteFileCompletedArg arg)
            {
                e.Result = arg.Path;
            };
            downloader.Download();
        }
Exemple #3
0
        private static string Path(BeatmapsetPackage p)
        {
            const string uriRoot = "https://bloodcat.com/osu/";

            return(uriRoot + "s/" + p.BeatmapsetId);
        }
Exemple #4
0
 public Bloodcat(BeatmapsetPackage package) : base(package)
 {
 }
Exemple #5
0
        static void Main(string[] args)
        {
            Console.Title = "osi_Console";
            Console.WriteLine("START");

            Configuration config      = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            var           appsettings = config.AppSettings.Settings;

            string InsoCookie;
            string BloodcatCookie;

            if (appsettings["FirstRun"].Value == "true")
            {
                string httpHash, httpsHash;

                RegisterAsDefaultBrowserFunction.Register(out httpHash, out httpsHash);
                if (httpHash != null)
                {
                    appsettings["HttpHash"].Value = httpHash;
                }
                if (httpsHash != null)
                {
                    appsettings["HttpsHash"].Value = httpsHash;
                }

                while (!(InputCookieFunction.InputInsoCookie(out InsoCookie) | InputCookieFunction.InputBloodcatCookie(out BloodcatCookie)))
                {
                    Console.WriteLine("请至少满足一个服务器的需求。");
                }
                if (InsoCookie != null)
                {
                    appsettings["InsoCookie"].Value = InsoCookie;
                }
                if (BloodcatCookie != null)
                {
                    appsettings["BloodcatCookie"].Value = BloodcatCookie;
                }
                appsettings["FirstRun"].Value = "false";
            }
            else
            {
                RegisterAsDefaultBrowserFunction.RegisterAsDefaultBrowser(appsettings["HttpHash"].Value, appsettings["HttpsHash"].Value);

                InsoCookie     = appsettings["InsoCookie"].Value;
                BloodcatCookie = appsettings["BloodcatCookie"].Value;
                if (InsoCookie != null)
                {
                    if (!Inso.IsCookieValid(InsoCookie))
                    {
                        Console.WriteLine("Inso Cookie已失效 请重新输入。");
                        InputCookieFunction.InputInsoCookie(out InsoCookie);
                        appsettings["InsoCookie"].Value = InsoCookie;
                    }
                    else
                    {
                        Console.WriteLine("do_not_remove_this_0w0" + " = " + InsoCookie);
                        Console.WriteLine("Inso Cookie有效。");
                    }
                }
                if (BloodcatCookie != null)
                {
                    if (!Bloodcat.IsCookieValid(BloodcatCookie))
                    {
                        Console.WriteLine("Bloodcat Cookie已失效 请重新输入。");
                        InputCookieFunction.InputBloodcatCookie(out BloodcatCookie);
                        appsettings["BloodcatCookie"].Value = BloodcatCookie;
                    }
                    else
                    {
                        Console.WriteLine("obm_human" + " = " + BloodcatCookie);
                        Console.WriteLine("Bloodcat Cookie有效。");
                    }
                }
            }
            config.Save();
            Console.CancelKeyPress += delegate(object sender, ConsoleCancelEventArgs e)
            {
            };

            DownloadManager downloadMgr = new DownloadManager();

            if (InsoCookie != null)
            {
                downloadMgr.Config(InsoCookie, Server.Inso, true);
            }
            if (BloodcatCookie != null)
            {
                downloadMgr.Config(BloodcatCookie, Server.Blooadcat, true);
            }
            downloadMgr.MaxDownloaderCount = 2;
            downloadMgr.FileWriter         = DownloadHepler.FileHelper.FileWrite;

            Console.WriteLine("Start Monitor", System.Drawing.Color.White);
            NamedPipeServerStream server = new NamedPipeServerStream("osi", PipeDirection.In);

            while (true)
            {
                server.WaitForConnection();

                StreamReader sr   = new StreamReader(server);
                string       link = sr.ReadToEnd();
                Console.WriteLine("Get Link" + " " + link);

                try
                {
                    BeatmapsetPackage package = new BeatmapsetPackage(new Beatmapset(link));
                    package.GetInfoCompleted += delegate(object sender, BeatmapsetPackage.BeatmapsetInfo e)
                    {
                        Console.WriteLine(e.beatmapsetId + " " + e.artist + "-" + e.title);
                    };
                    package.DownloadProgressChanged += delegate(object sender, BeatmapsetPackage.DownloadProgressChangedArgs e)
                    {
                        Console.WriteLine(e.Status);
                    };
                    package.WriteFileCompleted += delegate(object sender, BeatmapsetPackage.WriteFileCompletedArg e)
                    {
                        System.Diagnostics.Process.Start(e.Path);
                    };
                    downloadMgr.Add(package);
                }
                catch (Beatmapset.NotValidUri e)
                {
                }

                server.Disconnect();
            }
        }
Exemple #6
0
 public Server(BeatmapsetPackage package)
 {
     _beatmapsetPackage = package;
 }
Exemple #7
0
 public Inso(BeatmapsetPackage package) : base(package)
 {
 }