ScoreSaberDatabase.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using Newtonsoft.Json;
  2. using SimpleJSON;
  3. using SongBrowser.Logging;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Diagnostics;
  7. using Logger = SongBrowser.Logging.Logger;
  8. namespace SongBrowser.DataAccess
  9. {
  10. public class ScoreSaberSong
  11. {
  12. public string song { get; set; }
  13. public string mapper { get; set; }
  14. public List<ScoreSaberSongDifficultyStats> diffs { get; set; }
  15. }
  16. public class ScoreSaberSongDifficultyStats
  17. {
  18. public string diff { get; set; }
  19. public long scores { get; set; }
  20. public double star { get; set; }
  21. public double pp { get; set; }
  22. }
  23. public class ScoreSaberDataFile
  24. {
  25. public Dictionary<String, ScoreSaberSong> SongHashToScoreSaberData = null;
  26. public ScoreSaberDataFile(byte[] data)
  27. {
  28. Stopwatch timer = new Stopwatch();
  29. timer.Start();
  30. System.Globalization.NumberStyles style = System.Globalization.NumberStyles.AllowDecimalPoint;
  31. string result = System.Text.Encoding.UTF8.GetString(data);
  32. SongHashToScoreSaberData = JsonConvert.DeserializeObject<Dictionary<string, ScoreSaberSong>>(result);
  33. timer.Stop();
  34. Logger.Debug("Processing ScoreSaber data took {0}ms", timer.ElapsedMilliseconds);
  35. }
  36. }
  37. }