Advertisement
Guest User

Untitled

a guest
Mar 25th, 2024
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.20 KB | Software | 0 0
  1. #!/bin/python
  2.  
  3. import os
  4. import requests
  5.  
  6. # Function to get the game name from Steam's Web API
  7. def get_game_name(appid):
  8.     response = requests.get(f"https://store.steampowered.com/api/appdetails?appids={appid}")
  9.     if response.status_code == 200:
  10.         data = response.json()
  11.         if str(appid) in data and data[str(appid)]['success']:
  12.             return data[str(appid)]['data']['name']
  13.     return None
  14.  
  15. # Create a dictionary of AppIDs from folder names
  16. appid_dict = {folder: folder for folder in os.listdir('.') if os.path.isdir(folder) and os.path.islink(folder) == False}
  17.  
  18. # Scan and remove symbolic links that point to non-existent folders
  19. for link in os.listdir('.'):
  20.     if os.path.islink(link):
  21.         target = os.readlink(link)
  22.         if not os.path.exists(target):
  23.             os.remove(link)
  24.  
  25. # Create symbolic links with game names instead of AppIDs
  26. for appid, folder in appid_dict.items():
  27.     game_name = get_game_name(appid)
  28.     if game_name:
  29.         safe_game_name = game_name.replace(' ', '_')
  30.         if not os.path.exists(safe_game_name):
  31.             os.symlink(folder, safe_game_name)
  32.     else:
  33.         print(f"Could not find game name for AppID: {appid}")
  34.  
  35.  
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement