Skip to content

Instantly share code, notes, and snippets.

@97997
Created April 16, 2023 20:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 97997/c2e7679fb9426ad314b0db1042d3d85a to your computer and use it in GitHub Desktop.
Save 97997/c2e7679fb9426ad314b0db1042d3d85a to your computer and use it in GitHub Desktop.
Given a list of games with their launch URL command asks the user if it wants to play a random game
#Example of list.txt file
'''
Deathsmiles@@steam://rungameid/314180
Mushihimesama@@steam://rungameid/377860
Playnite Game@@playnite://playnite/start/6108f780-32bf-46c8-8db5-7aa626cfbfdf
'''
import webbrowser
import random
while True:
gameData = {}
# open the file for reading
with open('list.txt', 'r') as f:
# read each line and split it into two parts
for line in f:
parts = line.strip().split('@@')
# append the parts to the corresponding lists
gameData[parts[0]] = parts[1]
keys_list = list(gameData.keys())
random.shuffle(keys_list)
while len(keys_list)>0:
currentItem = keys_list.pop()
userChoice = input(f"Do you want to play {currentItem}? (Y/N)").lower()
if userChoice == "y":
print(f"Launching {currentItem}...")
gameCommand = gameData[currentItem]
webbrowser.open(gameCommand)
print("List got empty, starting again from the begining")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment