Created
April 16, 2023 20:26
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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