Advertisement
yanirx

Get Steam games list as text file

Apr 28th, 2014
470
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.85 KB | None | 0 0
  1. import urllib2
  2. import json
  3.  
  4. gameslist = []
  5.  
  6. key = '' # http://steamcommunity.com/dev/apikey
  7. steamid = '' # steam64 id, example: 76561198077896435
  8.  
  9. url = 'http://api.steampowered.com/IPlayerService/GetOwnedGames/v0001/?key=' + key + '&steamid=' + steamid + '&format=json'
  10. applist = 'http://api.steampowered.com/ISteamApps/GetAppList/v2'
  11.  
  12. print "Retrieving user data..",
  13. response = urllib2.urlopen(url)
  14. userdata = json.load(response)
  15. print " ok"
  16.  
  17. print "Retrieving app data.. (might take a while)",
  18. response = urllib2.urlopen(applist)
  19. appdata = json.load(response)
  20. print " ok"
  21.  
  22. for i in userdata["response"]["games"]:
  23.     for p in appdata["applist"]["apps"]:
  24.         if p["appid"] == i["appid"]:
  25.             gameslist.append(p["name"].encode("utf-8"))
  26.  
  27. print "Saving to file..",
  28. f = open(steamid + '.txt', 'wb')
  29. f.write('\n'.join(gameslist))
  30. f.close()
  31. print " ok"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement