From 1812553c9b8839b2e69b452ae19ffddcce5cdb84 Mon Sep 17 00:00:00 2001 From: Elijah Steres Date: Mon, 28 Dec 2020 10:27:20 -0500 Subject: [PATCH] cache player retrieved from collection url --- onomancer.py | 4 +++- the_prestige.py | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/onomancer.py b/onomancer.py index bbd00fa..c5fbe14 100644 --- a/onomancer.py +++ b/onomancer.py @@ -30,7 +30,9 @@ def get_scream(username): return scream def get_collection(collection_url): - # TODO: should probably add collection cache response = requests.get(onomancer_url + collection_hook + urllib.parse.quote(collection_url)) if response.status_code == 200: + for player in response.json()['lineup'] + response.json()['rotation']: + db.cache_stats(player['name'], json.dumps(player)) + return json.dumps(response.json()) \ No newline at end of file diff --git a/the_prestige.py b/the_prestige.py index 49b8e15..256d5ce 100644 --- a/the_prestige.py +++ b/the_prestige.py @@ -749,8 +749,7 @@ def build_star_embed(player_json): embed.add_field(name=starkeys[key], value=embedstring, inline=False) return embed -def team_from_collection(collection_raw): - newteam_json = json.loads(collection_raw) +def team_from_collection(newteam_json): # verify collection against our own restrictions if len(newteam_json["fullName"]) > 30: raise CommandError("Team names have to be less than 30 characters! Try again.")