2021-06-05 22:34:59 +00:00
|
|
|
#!/usr/bin/python3
|
|
|
|
import random, glob, os, json
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
|
|
|
script_dir = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
|
|
|
|
if not os.path.isfile(f"{script_dir}/state.json"):
|
|
|
|
# create state file if it doesnt exist
|
|
|
|
with open(f"{script_dir}/state.json", "w") as f:
|
|
|
|
state = {"current_song_type": "jingle"}
|
|
|
|
json.dump(state, f, indent=4)
|
|
|
|
else:
|
|
|
|
with open(f"{script_dir}/state.json") as f:
|
|
|
|
state = json.load(f)
|
|
|
|
|
|
|
|
if state["current_song_type"] == "song":
|
|
|
|
state["current_song_type"] = "jingle"
|
|
|
|
print(random.choice(glob.glob(f"{script_dir}/jingles/*.ogg")))
|
|
|
|
elif state["current_song_type"] == "jingle":
|
|
|
|
state["current_song_type"] = "song"
|
|
|
|
print(random.choice(glob.glob(f"{script_dir}/songs/*.ogg")))
|
|
|
|
else:
|
|
|
|
exit(1)
|
2021-06-05 22:44:09 +00:00
|
|
|
|
|
|
|
with open(f"{script_dir}/state.json", "w") as f:
|
|
|
|
json.dump(state, f, indent=4)
|