patrlim-musicshite/main.py
2024-06-29 14:49:36 -07:00

19 lines
No EOL
612 B
Python

import os
os.system('git pull')
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://github.com/patrlim/musicshite/raw/main/' + file.replace(" ","%20") + '"' + "\n }")
if i != len(os.listdir()):
jsonfile.write(",")
jsonfile.write("\n")
jsonfile.write(' ]\n}')