forked from SmmServer/NintendoClients
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsmm_postprocess.py
86 lines (72 loc) · 2.5 KB
/
smm_postprocess.py
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
from nintendo.nex import backend, service, kerberos, \
authentication, secure, datastoresmm, common
from nintendo.games import SMM
import glob
import ntpath
settings = backend.Settings("default.cfg")
settings.set("nex.access_key", SMM.ACCESS_KEY)
settings.set("nex.version", SMM.NEX_VERSION)
settings.set("prudp.silence_timeout", 10.0)
unkdata_files = glob.glob("./smm_scrape/unkdatas*.bin")
unkid = []
unkdata = []
for file in unkdata_files:
f = open(file, "rb")
data = f.read()
f.close()
stream = common.streams.StreamIn(data, settings)
blub = stream.list(stream.qbuffer)
bfile = ntpath.basename(file)
id = int(bfile[8:-4])
unkid.append(id)
unkdata.append(blub)
unkstream = common.streams.StreamOut(settings)
unkstream.u32(len(unkdata))
for i in range(0, len(unkdata)):
unkstream.u64(unkid[i])
unkstream.list(unkdata[i], unkstream.qbuffer)
f = open("smm_unkdata.bin", "wb")
f.write(unkstream.get())
f.close()
smm_mii_files = glob.glob("./smm_scrape/*smm_miidatas*.bin")
smm_mii_infos = []
for file in smm_mii_files:
f = open(file, "rb")
stream = common.streams.StreamIn(f.read(), settings)
infos = stream.list(datastoresmm.DataStoreCustomRankingResult)
for info in infos:
smm_mii_infos.append(info)
f.close()
smm_mii_stream = common.streams.StreamOut(settings)
smm_mii_stream.list(smm_mii_infos, smm_mii_stream.add)
f = open("smm_miidata.bin", "wb")
f.write(smm_mii_stream.get())
f.close()
course_files = glob.glob("./smm_scrape/coursedatas*.bin")
course_infos = []
for file in course_files:
f = open(file, "rb")
stream = common.streams.StreamIn(f.read(), settings)
infos = stream.list(datastoresmm.DataStoreCustomRankingResult)
for info in infos:
course_infos.append(info)
f.close()
coursedata_stream = common.streams.StreamOut(settings)
coursedata_stream.list(course_infos, coursedata_stream.add)
f = open("smm_coursedata.bin", "wb")
f.write(coursedata_stream.get())
f.close()
ranking_files = glob.glob("./smm_scrape/ranking*.bin")
rankings = []
for file in ranking_files:
f = open(file, "rb")
stream = common.streams.StreamIn(f.read(), settings)
ranking = stream.extract(datastoresmm.CourseRecordInfo)
rankings.append(ranking)
f.close()
rankings_stream = common.streams.StreamOut(settings)
rankings_stream.list(rankings, rankings_stream.add)
f = open("smm_rankings.bin", "wb")
f.write(rankings_stream.get())
f.close()
print("END")