Skip to content

Instantly share code, notes, and snippets.

@insanityseanboy
Created December 21, 2018 09:35
Show Gist options
  • Save insanityseanboy/d2cd478031daeb13a5365d2c8347049a to your computer and use it in GitHub Desktop.
Save insanityseanboy/d2cd478031daeb13a5365d2c8347049a to your computer and use it in GitHub Desktop.
Intersection of steam games
# usage: python .\steam_intersect.py APIKEY 76561198040368682 76561197972726018 76561198082711041
import urllib.request, json
from sys import argv
argv.pop(0)
apikey = argv.pop(0)
# "76561198040368682" me
# "76561197972726018" ed
# "76561198082711041" dyl
intersect = {}
for steamid in argv: #steamids:
urlGetGames = "http://api.steampowered.com/IPlayerService/GetOwnedGames/v0001/?key="+apikey+"&steamid="+steamid+"&format=json&include_appinfo=1" # &input_json={\"steamid\":"+steamid+"}
with urllib.request.urlopen(urlGetGames) as url:
data = json.loads(url.read().decode())
#print(data)
if (data["response"]):
for g in data["response"]["games"]:
if (g["name"] in intersect):
intersect[g["name"]]+=1
else:
intersect[g["name"]]=1
print(str(len(data["response"]["games"]))+ " games found for: "+steamid)
else:
print("ERROR: Could not get game list for: "+steamid)
for g in intersect:
if intersect[g]==len(argv):
print (g)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment