# This file lists everything in gamelist.xml import os import shutil import urllib.request as urllib import requests import xml.etree.ElementTree as ET #Set authorization GRIDTOKEN = r'' HEADERS = {'Authorization': 'Bearer ' + GRIDTOKEN} #define output locations shortcutloc = r"C:\Users\username\Desktop\Steam Games" graphicloc = r"C:\Program Files (x86)\Steam\userdata\35665403\config\grid" steamloc = r'"C:\Program Files (x86)\Steam\steam.exe"' metaloc = r"C:\Users\username\Desktop\Steam Games\Meta" coverloc = r"C:\Users\username\Desktop\Steam Games\Meta\Covers" logoloc = r"C:\Users\username\Desktop\Steam Games\Meta\Logos" artloc = r"C:\Users\username\Desktop\Steam Games\Meta\Arts" screenshotloc = r"C:\Users\username\Desktop\Steam Games\Meta\Screenshots" moviesloc = r"C:\Users\username\Desktop\Steam Games\Meta\Movies" #make sure directories exist os.makedirs(metaloc, exist_ok=True) os.makedirs(coverloc, exist_ok=True) os.makedirs(logoloc, exist_ok=True) os.makedirs(artloc, exist_ok=True) os.makedirs(screenshotloc, exist_ok=True) os.makedirs(moviesloc, exist_ok=True) #define location of xml files fp = open(r"C:\Users\username\Desktop\Steam Games\steamgames.xml","r") doc = ET.parse(fp) for game in doc.findall('games/game'): appID = game.find('appID') name = game.find('name') if name.text.find(":") > -1: gameFileName = name.text[0:name.text.find(":")] gameAppId = appID.text else: if name.text.find("(") > -1: gameFileName = name.text[0:name.text.find("(")] gameAppId = appID.text else: gameFileName = name.text gameAppId = appID.text print (gameFileName + " : " + gameAppId) #pull from json steam_url = r"https://store.steampowered.com/api/appdetails?appids=" + gameAppId resp = requests.get(steam_url) steam_json = resp.json() print (resp) #pull from steam try: shotssrcfull = str(steam_json[gameAppId]['data']['screenshots'][0]['path_full']) except: print ("no screenshot") try: moviesrcfull = str(steam_json[gameAppId]['data']['movies'][0]['mp4']['480']) except: print ("no movies") try: description = str(steam_json[gameAppId]['data']['short_description']) except: print ("no description") #pull from steamdb steamgrid_url = r"https://www.steamgriddb.com/api/v2/games/steam/" + gameAppId try: with requests.Session() as s: s.headers.update(HEADERS) resp = s.get(steamgrid_url) steamid_json = resp.json() #print (steamid_json) gameid = str(steamid_json['data']['id']) print ("steamid " + gameid) # steamdb logos griddb_url = r"https://www.steamgriddb.com/api/v2/logos/game/" + gameid gridresp = s.get(griddb_url) grid_json = gridresp.json() #print (grid_json) except: print ("unable to find game") try: logosrcfull2 = str(grid_json['data'][0]['url']) # print ("Logo URL: " + logosrcfull2) except: print ("no logo image") # steamdb covers try: griddb_url = r"https://www.steamgriddb.com/api/v2/heroes/game/" + gameid gridresp = s.get(griddb_url) grid_json = gridresp.json() coversrcfull2 = str(grid_json['data'][0]['url']) # print ("Cover URL: " + coversrcfull2) except: print ("no cover image") # steam db arts try: griddb_url = r"https://www.steamgriddb.com/api/v2/grids/game/" + gameid gridresp = s.get(griddb_url) grid_json = gridresp.json() artssrcfull2 = str(grid_json['data'][0]['url']) #print ("Arts URL: " + artssrcfull2) except: print ("no grid image") #other graphic sources graphicsource = r"https://cdn.akamai.steamstatic.com/steam/apps/" + gameAppId + r"/" coversrcfull = graphicsource + "library_600x900_2x.jpg" logosrcfull = graphicsource + "logo.png" artssrcfull = graphicsource + "header.jpg" #print ("screenshot " + screenshot) #print ("movie " + moviesrcfull) #print ("description " + description) #create gfbatchname gfbatchname = shortcutloc + "\\" + gameFileName + ".bat" #create batch files myBat = open(gfbatchname,'w+') myBat.write(steamloc +' -silent -high -highjack -applaunch ' + gameAppId + "/R" + "timeout //T 10 Taskkill //IM steam.exe //F") myBat.close() #graphic location directory #covers try: coverdestfull = coverloc + "\\" + gameFileName + ".png" resource = urllib.urlopen(coversrcfull) output = open(coverdestfull,"wb") output.write(resource.read()) output.close() except: try: coverdestfull = coverloc + "\\" + gameFileName + ".png" resource = urllib.urlopen(coversrcfull2) output = open(coverdestfull,"wb") output.write(resource.read()) output.close() except: try: coverdestfull = coverloc + "\\" + gameFileName + ".png" resource = urllib.urlopen(artssrcfull) output = open(coverdestfull,"wb") output.write(resource.read()) output.close() except: try: coverdestfull = coverloc + "\\" + gameFileName + ".png" resource = urllib.urlopen(artssrcfull2) output = open(coverdestfull,"wb") output.write(resource.read()) output.close() except: print ("skipping cover") #logos try: logodestfull = logoloc + "\\" + gameFileName + ".png" resource = urllib.urlopen(logosrcfull) output = open(logodestfull,"wb") output.write(resource.read()) output.close() except: try: logodestfull = logoloc + "\\" + gameFileName + ".png" resource = urllib.urlopen(logosrcfull2) output = open(logodestfull,"wb") output.write(resource.read()) output.close() except: print ("skipping logos") #art try: artdestfull = artloc + "\\" + gameFileName + ".png" resource = urllib.urlopen(artssrcfull) output = open(artdestfull,"wb") output.write(resource.read()) output.close() except: try: artdestfull = artloc + "\\" + gameFileName + ".png" resource = urllib.urlopen(artssrcfull2) output = open(artdestfull,"wb") output.write(resource.read()) output.close() except: print ("skipping art") #screenshots try: shotsdestfull = screenshotloc + "\\" + gameFileName + ".png" resource = urllib.urlopen(shotssrcfull) output = open(shotsdestfull,"wb") output.write(resource.read()) output.close() except: print ("skipping screenshots") #movies moviesrcfull try: moviedestfull = moviesloc + "\\" + gameFileName + ".mp4" resource = urllib.urlopen(moviesrcfull) output = open(moviedestfull,"wb") output.write(resource.read()) output.close() except: print ("skipping movies")