From b2fefef30b2af2560d488b33d54fbafcc9449e57 Mon Sep 17 00:00:00 2001 From: Akkie100 Date: Wed, 17 Nov 2021 17:53:57 +0100 Subject: [PATCH] Fixed story_id issue, close #77 I think this works... --- src/alerts/api.py | 8 ++++++-- src/alerts/genes.py | 19 ++++++------------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/alerts/api.py b/src/alerts/api.py index 295cf1c..5968207 100644 --- a/src/alerts/api.py +++ b/src/alerts/api.py @@ -16,8 +16,12 @@ async def api_genes(ids: str): async with session.get( "https://api.axie.technology/getgenes/" + ids + "/all" ) as r: - return await r.json() - + response = await r.json() + if 'message' in response.keys(): + raise Exception('Stupid Genes API') + else: + return response + @retry(stop=stop_after_attempt(12), wait=wait_fixed(5)) async def api_new_listings(): diff --git a/src/alerts/genes.py b/src/alerts/genes.py index a4251cc..71ee5f7 100644 --- a/src/alerts/genes.py +++ b/src/alerts/genes.py @@ -36,20 +36,13 @@ async def get_genes(axie_df, r1, r2, get_auction_info=False): genes = pd.DataFrame(response) # Remove ids of axies that are currently in the API as eggs - try: - genes = genes.loc[ - ~genes.story_id.isin(genes[genes.stage == 1]["story_id"].tolist()) - ] - - # Remove nan ids - genes = genes[genes["story_id"].notna()] - - except Exception as e: - print(e) - print("Error with story_id!!!") - with pd.option_context("display.max_rows", None, "display.max_columns", None): - print(axie_df) + genes = genes.loc[ + ~genes.story_id.isin(genes[genes.stage == 1]["story_id"].tolist()) + ] + # Remove nan ids + genes = genes[genes["story_id"].notna()] + # Add columns for parts for part in ["eyes", "ears", "mouth", "horn", "back", "tail"]: try: