mirror of
https://github.com/creyD/asiimov.git
synced 2026-06-16 18:50:19 +02:00
Added Steam API Queries
This commit is contained in:
@@ -4,6 +4,7 @@ from django.contrib.auth.models import User
|
|||||||
# For catching the save method for keeping user objects in sync
|
# For catching the save method for keeping user objects in sync
|
||||||
from django.db.models.signals import post_save
|
from django.db.models.signals import post_save
|
||||||
from django.dispatch import receiver
|
from django.dispatch import receiver
|
||||||
|
from .steam_api import getUserInfo
|
||||||
|
|
||||||
# CHOICE HELPERS
|
# CHOICE HELPERS
|
||||||
BADGE_RARITIES = [
|
BADGE_RARITIES = [
|
||||||
|
|||||||
23
src/core/steam_api.py
Normal file
23
src/core/steam_api.py
Normal file
@@ -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
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
{% extends 'master.html' %}
|
{% extends 'master.html' %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
TESt
|
<h1>About</h1>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
Reference in New Issue
Block a user