aboutsummaryrefslogtreecommitdiff
path: root/site/sound/refresh_map.py
diff options
context:
space:
mode:
authorRichard <q@1bpm.net>2025-04-13 18:48:02 +0100
committerRichard <q@1bpm.net>2025-04-13 18:48:02 +0100
commit9fbf91db06a6d4f4b5cd8bb45389a731bb86bf22 (patch)
tree291bd79ce340e67affa755a8a6b4f6a83cce93ea /site/sound/refresh_map.py
downloadapps.csound.1bpm.net-9fbf91db06a6d4f4b5cd8bb45389a731bb86bf22.tar.gz
apps.csound.1bpm.net-9fbf91db06a6d4f4b5cd8bb45389a731bb86bf22.tar.bz2
apps.csound.1bpm.net-9fbf91db06a6d4f4b5cd8bb45389a731bb86bf22.zip
initial
Diffstat (limited to 'site/sound/refresh_map.py')
-rw-r--r--site/sound/refresh_map.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/site/sound/refresh_map.py b/site/sound/refresh_map.py
new file mode 100644
index 0000000..74b9dff
--- /dev/null
+++ b/site/sound/refresh_map.py
@@ -0,0 +1,31 @@
+import json
+import os
+import re
+
+base_url = "/sound"
+
+def refresh():
+ items = dict()
+ for item in os.listdir("."):
+ if os.path.isdir(item):
+ sounds = list()
+ first = True
+ coltype = "generic"
+ for sound in os.listdir(item):
+ if os.path.splitext(sound)[1].lower() == ".mp3":
+ if first:
+ first = False
+ if re.search(r"[0-9]{2}.[0-9].mp3", sound):
+ coltype = "melsys"
+ soundobj = {"path": os.path.join(base_url, item, sound)}
+ if coltype == "melsys":
+ soundobj["note"] = int(re.match(r"([0-9]{2}).[0-9].mp3", sound).group(1))
+ sounds.append(soundobj)
+ items[item] = {"type": coltype, "sounds": sounds}
+
+ with open("map.json", "w") as f:
+ json.dump(items, f)
+
+if __name__ == "__main__":
+ refresh()
+