-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJSON.cs
More file actions
60 lines (49 loc) · 2.02 KB
/
JSON.cs
File metadata and controls
60 lines (49 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
namespace osuAnticheat___2020_07_06
{
class JSON
{
[JsonPropertyName("file_version")]
public string FileVersion { get; set; }
[JsonPropertyName("filename")]
public string FileName { get; set; }
[JsonPropertyName("file_hash")]
public string FileMD5 { get; set; }
[JsonPropertyName("filesize")]
public string FileSize { get; set; }
[JsonPropertyName("timestamp")]
public string Timestamp { get; set; }
[JsonPropertyName("patch_id")]
public string PatchID { get; set; }
[JsonPropertyName("url_full")]
public string FileURL { get; set; }
public static void GetBuildProperties(out Dictionary<string, JSON> buildFiles, out string osuBuild)
{
osuBuild = "";
buildFiles = new Dictionary<string, JSON>();
string[] buildNames = { "stable", "stable40", "beta40", "cuttingedge" };
string jsonBuffer = "";
foreach (string build in buildNames)
{
string buffer = Variables.wc.DownloadString("https://osu.ppy.sh/web/check-updates.php?action=check&stream=" + build).Replace(@"\", "");
if (buffer.Contains("invalid"))
continue;
string hash = Regex.Match(buffer, "(e\",\"file_hash\":\".*?\")").Value.Split(':')[1].Replace("\"", "");
if (hash == Program.osuExeMD5)
{
osuBuild = build;
jsonBuffer = buffer;
break;
}
}
foreach (Match m in Regex.Matches(jsonBuffer, "({.*?})"))
{
JSON deserialized = JsonSerializer.Deserialize<JSON>(m.Value);
buildFiles.Add(deserialized.FileName, deserialized);
}
}
}
}