-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathfiles.py
32 lines (23 loc) · 956 Bytes
/
files.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
import os
import glob
from pathlib import Path
from pprint import pprint
p = Path("static/sounds/")
sounds = {"Captain Holt": [], "Terry Jeffords": [], "Charles Boyle": [], "Jake Peralta": [], "Gina Linetti": [], "Rosa Diaz": [], "Amy Santiago": [], "Hitchcock": [], "Scully": [], "Captain CJ": [], "Doug Judy": [], "Kevin": []}
characters = list(sounds.keys())
for i in p.glob('**/*.mp3'):
sound_path = str(i).split("sounds/")[1]
# make sure not system file
if not (sound_path[0] == "."):
character, filename = sound_path.split('/')[0], sound_path.split('/')[1]
try: sounds[character].append(filename)
except: sounds[character] = [filename]
for char, list in sounds.items():
sounds[char].sort()
# pprint(sounds)
# write to ../contents/sounds.js
file = open('contents/sounds.js', 'w')
file.write(f"export let sounds = {str(sounds)};\n" )
file.write(f"export let characters = {str(characters)};")
file.close()
print("Done.")