This repository has been archived by the owner on Jun 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
sound_harvester.py
51 lines (46 loc) · 1.67 KB
/
sound_harvester.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
import json
def strip_sounds(sound_definitions: str):
'''
This function assumes that the sounds definition file uses 1.14.0
sounds_definitions.json file format. It doesn't work for older files
and may not work in the future.
'''
print("Sound definitions!")
with open(sound_definitions) as json_file:
data = list(json.load(json_file)['sound_definitions'].keys())
outfile = open("sound_out.md", "w+")
#Collect sounds for the linker
save = ""
mob = ""
for sound in data:
if "." in sound:
current = sound.split(".")[0]
mob_current = sound.split(".")[1]
if(save != current):
outfile.write(" - [{0}](##{0})\n".format(current))
save = current
if(current == "mob" and mob != mob_current):
mob = mob_current
outfile.write(" - [{0}](##{0})\n".format(mob_current))
else:
current = sound
outfile.write(" - [{0}](##{0})\n".format(current))
save = current
id = ""
mob = ""
for sound in data:
if "." in sound:
current = sound.split(".")[0]
mob_current = sound.split(".")[1]
if(id != current):
outfile.write("## " + current + "\n\n")
id = current
if(id == "mob" and mob != mob_current):
mob = mob_current
outfile.write("## " + mob_current + "\n\n")
outfile.write("`" + sound + "`\n\n")
else:
current = sound
outfile.write("# " + current + "\n\n")
outfile.write("`" + sound + "`\n\n")
save = current