Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/python
- import os
- import requests
- # Function to get the game name from Steam's Web API
- def get_game_name(appid):
- response = requests.get(f"https://store.steampowered.com/api/appdetails?appids={appid}")
- if response.status_code == 200:
- data = response.json()
- if str(appid) in data and data[str(appid)]['success']:
- return data[str(appid)]['data']['name']
- return None
- # Create a dictionary of AppIDs from folder names
- appid_dict = {folder: folder for folder in os.listdir('.') if os.path.isdir(folder) and os.path.islink(folder) == False}
- # Scan and remove symbolic links that point to non-existent folders
- for link in os.listdir('.'):
- if os.path.islink(link):
- target = os.readlink(link)
- if not os.path.exists(target):
- os.remove(link)
- # Create symbolic links with game names instead of AppIDs
- for appid, folder in appid_dict.items():
- game_name = get_game_name(appid)
- if game_name:
- safe_game_name = game_name.replace(' ', '_')
- if not os.path.exists(safe_game_name):
- os.symlink(folder, safe_game_name)
- else:
- print(f"Could not find game name for AppID: {appid}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement