From cf21bf0f0f641b4c69aa7eecc252a774a6c510a9 Mon Sep 17 00:00:00 2001 From: Hofei90 <29521028+hofei90@users.noreply.github.com> Date: Sun, 3 May 2020 23:18:36 +0200 Subject: [PATCH] Initialcommit --- db_model.py | 26 ++++++++++++++++++++++++++ get_cod_stats.py | 19 +++++++++++++++++++ requirements.txt | 3 +++ 3 files changed, 48 insertions(+) create mode 100644 db_model.py create mode 100644 get_cod_stats.py create mode 100644 requirements.txt diff --git a/db_model.py b/db_model.py new file mode 100644 index 0000000..a1cbd4e --- /dev/null +++ b/db_model.py @@ -0,0 +1,26 @@ +import peewee + + +database = peewee.Proxy() + + +class BaseModel(peewee.Model): + class Meta: + database = database + + +class CoDUser(BaseModel): + user = peewee.TextField() + + +class CoDStats(BaseModel): + ts = peewee.DateTimeField() + typ = peewee.TextField() + value = peewee.FloatField() + + class Meta: + primary_key = peewee.CompositeKey('ts', 'typ') + + +def create_tables(): + database.create_tables([TestPeewee]) diff --git a/get_cod_stats.py b/get_cod_stats.py new file mode 100644 index 0000000..be5ee7e --- /dev/null +++ b/get_cod_stats.py @@ -0,0 +1,19 @@ +""" +Links: +https://api.tracker.gg/api/v2/modern-warfare/standard/profile/battlenet/Hofei%232237 +https://api.tracker.gg/api/v2/modern-warfare/standard/profile/battlenet/Hofei%232237/segments/killstreak? +https://api.tracker.gg/api/v2/modern-warfare/standard/profile/battlenet/Hofei%232237/segments/weapon? +""" + +import requests +import json +import toml +import pprint + +URL = "https://api.tracker.gg/api/v2/modern-warfare/standard/profile/battlenet/Hofei%232237" +r = requests.get(URL) +j_r = json.loads(r.text) + +#pprint.pprint(j_r) + +print(j_r["data"]) \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..8fda0d7 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +peewee~=3.13.3 +requests~=2.23.0 +toml~=0.10.0 \ No newline at end of file