Skip to content

Commit cfc3666

Browse files
committed
Merge remote-tracking branch 'ppoelzl/dev' into dev
2 parents c4a46d9 + 81d4427 commit cfc3666

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed

src/scripts/convert_skill_data.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import io
2+
3+
import slpp
4+
5+
line_count = 0
6+
data = io.StringIO()
7+
data.write("{")
8+
with open("act_dex.lua") as fd:
9+
lines = fd.readlines()
10+
for line in lines:
11+
line = line.strip()
12+
# Ignore comments or local Lua defines
13+
if line.startswith("--") or line.startswith("local"):
14+
continue
15+
data.write(line)
16+
line_count += 1
17+
data.write("}")
18+
data.seek(0)
19+
20+
converted_data = slpp.slpp.decode(data.read())
21+
print(f"processed {line_count} lines")
22+
# for key in converted_data:
23+
# print(key)
24+
print(converted_data["AnimateWeapon"])

src/scripts/fetch_character.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import json
2+
import re
3+
from typing import Optional
4+
5+
import requests
6+
7+
HOST_NAME = "https://www.pathofexile.com/"
8+
CHARACTER_PATH = "character-window/get-characters"
9+
PROFILE_PATH = "account/view-profile/"
10+
PASSIVE_TREE_PATH = "character-window/get-passive-skills"
11+
12+
headers = {"User-Agent": "Path of Building Community", "Accept": ""}
13+
realm_code = "pc"
14+
15+
16+
def import_characters(account_name: str) -> Optional[tuple[str, dict]]:
17+
url = f"{HOST_NAME}{CHARACTER_PATH}"
18+
params = {"accountName": account_name, "realm": realm_code}
19+
try:
20+
response = requests.get(url, params=params, headers=headers, timeout=6.0)
21+
except requests.RequestException as e:
22+
print(f"Error retrieving account: {e}.")
23+
return
24+
print(response.url)
25+
characters = response.json()
26+
print(f"Character list:\n{json.dumps(characters, indent=4)}")
27+
url = f"{HOST_NAME}{PROFILE_PATH}{account_name}"
28+
try:
29+
response = requests.get(url, headers=headers, timeout=6.0)
30+
except requests.RequestException as e:
31+
print(f"Error retrieving character list: {e}.")
32+
return
33+
if m := re.search(r"/view-profile/(\w+)/characters", response.text):
34+
return m.group(1), characters
35+
36+
37+
def import_passive_tree(account_name: str, char_name: str):
38+
url = f"{HOST_NAME}{PASSIVE_TREE_PATH}"
39+
params = {"accountName": account_name, "character": char_name, "realm": realm_code}
40+
try:
41+
response = requests.get(url, params=params, headers=headers, timeout=6.0)
42+
except requests.RequestException as e:
43+
print(f"Error retrieving passive skill tree: {e}.")
44+
return
45+
passive_tree = response.json()
46+
print(f"Tree:\n{json.dumps(passive_tree, indent=4)}")
47+
48+
49+
if __name__ == "__main__":
50+
player_name = "GlobalIdentity"
51+
player_name, player_characters = import_characters(player_name)
52+
leagues = [c["name"] for c in player_characters if c["league"] == "Ritual"]
53+
print(leagues)
54+
import_passive_tree(player_name, leagues[1])

0 commit comments

Comments
 (0)