diff --git a/randomizermodule.py b/randomizermodule.py new file mode 100644 index 0000000..b55f066 --- /dev/null +++ b/randomizermodule.py @@ -0,0 +1,38 @@ +import os +import random + +if not os.path.exists("musiclist.txt"): + print("musiclist.txt not found") + exit() + +with open("musiclist.txt", "r") as f: + musiclist = f.readlines() + +def randomize(): + html = "\n\n\n\n\n\n\n" + html += "\n" + html += "Halhadus' Music List\n" + html += "\n" + html += "\n" + html += "\n" + html += "\n" + html += "\n" + html += "\n" + random.shuffle(musiclist) + html += "

Music List


\n" + html += "

Click on the music to listen


\n" + html += "

\n" + html += "

List is randomized. To see history of list and source codes of scripts which I used to generate this list, click here


\n" + html += """



\n""" + musiccount = 0 + for music in musiclist: + musiccount += 1 + music = music.strip().split(" --- ") + if music[2] == "YTM": + html += f"{musiccount}.{music[0]}
\n" + elif music[2] == "YT": + html += f"{musiccount}.{music[0]}
\n" + else: + print("Invalid provider") + html += f"Count: {musiccount}\n\n" + return html