You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.5 KiB

  1. using SimpleJSON;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace IllusionInjector.Updating.ModsaberML
  8. {
  9. class ApiEndpoint
  10. {
  11. const string ApiBase = "https://www.modsaber.ml/api/";
  12. const string GetApprovedEndpoint = "public/temp/approved";
  13. public class Mod
  14. {
  15. public string Name;
  16. public Version Version;
  17. public bool Approved;
  18. public string Title;
  19. public Version GameVersion;
  20. public string Author;
  21. public string SteamFile;
  22. public string OculusFile;
  23. public static Mod DecodeJSON(JSONObject obj)
  24. {
  25. var outp = new Mod
  26. {
  27. Name = obj["name"],
  28. Version = new Version(obj["version"]),
  29. Approved = obj["approved"].AsBool,
  30. Title = obj["title"],
  31. GameVersion = new Version(obj["gameVersion"]),
  32. Author = obj["author"]
  33. };
  34. foreach (var item in obj["files"].Keys)
  35. {
  36. var key = item as JSONString;
  37. if (key.Value == "steam")
  38. outp.SteamFile = obj[key.Value]["url"];
  39. if (key.Value == "oculus")
  40. outp.OculusFile = obj[key.Value]["url"];
  41. }
  42. return outp;
  43. }
  44. }
  45. }
  46. }