示例#1
0
        public void DownloadLastSuggest()
        {
            if (suggest_history_queue.Count == 0)
            {
                return;
            }

            BeatmapDownloadTask map = suggest_history_queue.Last();

            suggest_history_queue.RemoveLast();

            SendIRCMessage(string.Format(DefaultLanguage.LANG_START_DOWNLOAD, map.name));

            DownloadBeatmap(map);
        }
示例#2
0
        public void Push(int id, bool isSetId, string name)
        {
            if (capacity < suggest_history_queue.Count)
            {
                suggest_history_queue.RemoveFirst();
            }

            BeatmapDownloadTask task = new BeatmapDownloadTask()
            {
                id      = id,
                isSetId = isSetId,
                name    = name
            };

            suggest_history_queue.AddLast(task);

            IO.CurrentIO.Write($"[BeatmapSuggest]Push {name}");
        }
示例#3
0
        private async void DownloadBeatmap(BeatmapDownloadTask map)
        {
            await Task.Run(() =>
            {
                try
                {
                    if (!TryGetOsuSongFolder())
                    {
                        return;
                    }

                    int beatmap_setid = map.id;

                    //通过id获取对应的setid
                    if (!map.isSetId)
                    {
                        beatmap_setid = GetBeatmapSetID(map.id);
                        if (beatmap_setid < 0)
                        {
                            return;
                        }
                    }

                    IO.CurrentIO.WriteColor(string.Format(DefaultLanguage.LANG_START_DOWNLOAD, map.name), ConsoleColor.Green);

                    string download_url = $"http://osu.uu.gl/s/{beatmap_setid}";

                    WebClient wc = new WebClient();
                    wc.DownloadFile(new Uri(download_url), save_path + "\\" + $"{beatmap_setid} {map.name}.osz");

                    IO.CurrentIO.WriteColor(string.Format(DefaultLanguage.LANG_FINISH_DOWNLOAD, map.name), ConsoleColor.Green);
                }
                catch (Exception e)
                {
                    IO.CurrentIO.WriteColor(string.Format(DefaultLanguage.LANG_FAILED_DOWNLOAD, map.name, e.Message), ConsoleColor.Red);
                }
            });
        }