steam.py 971 B

123456789101112131415161718192021222324252627282930
  1. # pylint: disable=C0303
  2. import requests
  3. import json
  4. SteamUN = "Marorin"
  5. key = '231E98D442E52B87110816C3D5114A1D'
  6. def gamesPulling(steamID,key):
  7. # Returns the JSON data from the Steam API based of one's
  8. # Steam ID number and returns a dictionary of gameids and minutes played.
  9. steaminfo = {
  10. 'key': key,
  11. 'steamid': steamID,
  12. 'format':'JSON',
  13. 'include_appinfo':'1'
  14. }
  15. r = requests.get('http://api.steampowered.com/IPlayerService/GetOwnedGames/v0001/', params=steaminfo)
  16. d = json.loads(r.content)
  17. return d['response']['games']
  18. def steamIDPulling(SteamUN,key):
  19. #Pulls out and returns the steam id number for use in steam queries.
  20. steaminfo = {'key': key,'vanityurl': SteamUN}
  21. a = requests.get('http://api.steampowered.com/ISteamUser/ResolveVanityURL/v0001/', params=steaminfo)
  22. k = json.loads(a.content)
  23. SteamID = k['response']['steamid']
  24. return SteamID