From ed739b3d8aaeea649d6bfb87fd0c0d03128c86f0 Mon Sep 17 00:00:00 2001 From: Halhadus Date: Mon, 25 Nov 2024 03:27:09 +0300 Subject: [PATCH] Randomizer module for website added --- randomizermodule.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 randomizermodule.py 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