Пример #1
0
 public void GetInfo(string nameorid)
 {
     using (var client = new CustomWebClient())
     {
         //standard
         string json = client.DownloadString(GlobalVars.UserAPI + nameorid + GlobalVars.Mode + 3);
         Match match = Regex.Match(json, @"""user_id"":""(.+?)"".+?""username"":""(.+?)"".+?""pp_rank"":""(.+?)"".+?""level"":""(.+?)"".+?""pp_raw"":""(.+?)"".+?""country"":""(.+?)""");
         User_id = Convert.ToInt32(match.Groups[1].Value);
         Username = match.Groups[2].Value;
         PpRank = Convert.ToInt32(match.Groups[3].Value);
         Level = Convert.ToDouble(match.Groups[4].Value, CultureInfo.InvariantCulture);
         PpRaw = Convert.ToDouble(match.Groups[5].Value, CultureInfo.InvariantCulture);
         Country = match.Groups[6].Value;
         json = client.DownloadString(GlobalVars.UserBestAPI + User_id + GlobalVars.Mode + 3);
         BestScores = JsonSerializer.DeserializeFromString<List<UserBest>>(json);
     }
 }
Пример #2
0
 public Beatmap(int beatmapid)
 {
     using (var client = new CustomWebClient())
     {
         string json = client.DownloadString(GlobalVars.BeatmapAPI + beatmapid);
         Match match = Regex.Match(json, @"""beatmapset_id"":""(.+?)"".+?""total_length"":""(.+?)"".+?""hit_length"":""(.+?)"".+?""version"":""(.+?)"".+?""artist"":""(.+?)"".+?""title"":""(.+?)"".+?""creator"":""(.+?)"".+?""bpm"":""(.+?)"".+?""difficultyrating"":""(.+?)"".+?""mode"":""(.+?)""");
         BeatmapSet_id = Convert.ToInt32(match.Groups[1].Value);
         Beatmap_id = beatmapid;
         Total_length = Convert.ToInt32(match.Groups[2].Value);
         Hit_length = Convert.ToInt32(match.Groups[3].Value);
         Version = match.Groups[4].Value;
         Artist = match.Groups[5].Value;
         Title = match.Groups[6].Value;
         Creator = match.Groups[7].Value;
         Bpm = Convert.ToDouble(match.Groups[8].Value, CultureInfo.InvariantCulture);
         Difficultyrating = Convert.ToDouble(match.Groups[9].Value, CultureInfo.InvariantCulture);
         Mode = (GlobalVars.GameMode)Enum.Parse(typeof(GlobalVars.GameMode), match.Groups[10].Value);
         Url = GlobalVars.Beatmap + beatmapid;
         ThumbnailUrl = @"http://b.ppy.sh/thumb/" + BeatmapSet_id + "l.jpg";
         BloodcatUrl = GlobalVars.Bloodcat + BeatmapSet_id;
     }
 }