patrlim-musicshite/main.py
2024-07-08 10:06:35 -07:00

17 lines
No EOL
591 B
Python

import os
filelist = os.listdir()
jsonfile = open("songs.json", "w", encoding="utf-8")
jsonfile.write('{\n "songs":[\n')
i = 0
for file in filelist:
i += 1
if file[-4:] != ".ogg":
continue
jsonfile.write(" {\n" + ' "name":' + '"' + file.replace(".ogg","") + '",' + "\n")
jsonfile.write(' "url":' + '"' + 'https://git.merith.xyz/patrlim/musicshite/raw/main/' + file.replace(" ","%20") + '"' + "\n }")
if i != len(os.listdir()):
jsonfile.write(",")
jsonfile.write("\n")
jsonfile.write(' ]\n}')