ScoreSaberDatabase.cs 1.3 KB

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