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}')