diff --git a/src/core/models.py b/src/core/models.py index da2987a..4d2e383 100644 --- a/src/core/models.py +++ b/src/core/models.py @@ -4,6 +4,7 @@ from django.contrib.auth.models import User # For catching the save method for keeping user objects in sync from django.db.models.signals import post_save from django.dispatch import receiver +from .steam_api import getUserInfo # CHOICE HELPERS BADGE_RARITIES = [ diff --git a/src/core/steam_api.py b/src/core/steam_api.py new file mode 100644 index 0000000..c8158f7 --- /dev/null +++ b/src/core/steam_api.py @@ -0,0 +1,23 @@ +# For communication with the Steam API +import urllib.request +import json +# For getting the STEAM_API_KEY +from django.conf import settings + +STEAM_SERVER = 'https://api.steampowered.com/' +USER_METHOD = 'ISteamUser/GetPlayerSummaries/v2' +INVENTORY_SERVER = 'https://steamcommunity.com/inventory/' + + +# Get the mandatory gamer info for a gamer +def getUserInfo(steamID, API_KEY=settings.STEAM_API_KEY): + QUERY = STEAM_SERVER + USER_METHOD + '/?key=' + str(API_KEY) + '&format=json&steamids=' + str(steamID) + player_object = json.load(urllib.request.urlopen(QUERY)) + return player_object + + +# Get the CS:GO inventory of a gamer +def getUserInventory(steamID, API_KEY=settings.STEAM_API_KEY, GAME_ID=730): + QUERY = INVENTORY_SERVER + '/' + steamID + '/' + GAME_ID + '/2?l=english&count=5000' + inventory_object = json.load(urllib.request.urlopen(QUERY)) + return inventory_object diff --git a/src/core/templates/static_pages/about.html b/src/core/templates/static_pages/about.html index 979e3b2..7a35b05 100644 --- a/src/core/templates/static_pages/about.html +++ b/src/core/templates/static_pages/about.html @@ -1,5 +1,5 @@ {% extends 'master.html' %} {% block content %} -TESt +

About

{% endblock %}