-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsumnotables.py
145 lines (130 loc) · 5.1 KB
/
sumnotables.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
import base64,re,json,os
from urllib.parse import unquote
from dcdr import dcdr
import requests
vers = "3_17"
currentversion = 6 # not enirely sure how/where this was set in the original code but '6' seems to be the value we need!!
incleagues = ["Archnemesis","SSF Archnemesis","Hardcore Archnemesis","SSF Archnemesis HC"]
adbname = "atlas-skill-tree" + vers + ".json"
adb = {}
if os.path.exists(adbname):
with open(adbname) as json_file:
adb = json.load(json_file)
adbn = adb["nodes"]
ndbname = "acctdb.json"
ndb = {}
poesite = 'https://www.pathofexile.com'
session = requests.Session()
session.headers.update({'User-Agent': 'PoEApt'})
if os.path.exists(ndbname):
with open(ndbname) as json_file:
ndb = json.load(json_file)
else:
accounts = [
"mathil",
"zizaran",
"bigducks",
"yojimoji",
"steelmage",
"raizqt",
"ghazzy",
"thisisbadger",
"notscarytime",
"donthecrown",
"pohx",
"nugiyen",
"octavian0",
"thi3n",
"baker",
"catmaster",
"balormage",
"AsmodeusPOE",
"ventrua",
"Karvarousku",
"navandis",
"TheVictor003",
"dslily",
"alkaizerx",
"darkee",
"goratha",
"jorgo44"
]
for account in accounts:
apichars = session.get(f"{poesite}/character-window/get-characters?accountName={account}&realm=pc")
if apichars.status_code != 200:
print(f'Error: failed to read characters for account {account}')
else:
leagues = []
apichardb = apichars.json()
for apichar in apichardb:
if "league" in apichar and apichar["league"] in incleagues and apichar["league"] not in leagues:
leagues.append(apichar["league"])
for league in leagues:
response = session.get(f"{poesite}/character-window/view-atlas-skill-tree?accountName={account}&realm=pc&league={league}")
if response.status_code == 200:
# this is redirected to a URL which contains the string which we extract below
e = re.sub(r'.*\/', '', response.url)
# translated from GGG's code to decode the string
e = base64.b64decode(e.replace("-","+").replace("_","/"))
n = dcdr()
n.setDataString(e)
s = 0
a = 0
r = 0
l = []
o = []
h = []
v = n.readInt()
if v == 4:
s = n.readInt8()
a = n.readInt8()
r = n.readInt8()
while n.hasData():
l.append(n.readInt16())
elif v == 5:
s = n.readInt8()
a = n.readInt8()
c = n.readInt8()
for d in range(0,c):
l.append(n.readInt16())
u = n.readInt8()
for d in range(0,u):
o.append(n.readInt16())
elif v == currentversion:
s = n.readInt8()
a = n.readInt8()
c = n.readInt8()
for d in range(0,c):
l.append(str(n.readInt16()))
u = n.readInt8()
for d in range(0,u):
o.append(n.readInt16())
v = n.readInt8()
for d in range(0,v):
f = n.readInt()
h[65535 & f] = f >> 16
else:
print("The build you are trying to load is using an old version of the passive tree and will not work.")
print("Scanning ", account,league)
for an in l:
if an in adbn:
if "isNotable" in adbn[an]:
if an in ndb:
ndb[an]["count"] += 1
ndb[an]["acts"].append(account + "-" + league)
else:
ndb[an] = {
"count": 1,
"acts": [account + "-" + league]
}
with open(ndbname, 'w') as json_file:
json.dump(ndb, json_file, indent=4)
for n in sorted(ndb.items(),key=lambda x:x[1]["count"],reverse=True):
groupname = ""
if "group" in adbn[n[0]] and str(adbn[n[0]]["group"]) in adb["groups"]:
group = adb["groups"][str(adbn[n[0]]["group"])]
for node in group["nodes"]:
if "isMastery" in adbn[node]:
groupname = adbn[node]["name"]
break
print(ndb[n[0]]["count"],adbn[n[0]]["name"],"-",groupname)