Removed redundant code

pull/8/head
sgoudham 4 years ago
parent 63f65b6745
commit 42510ce4b7

@ -547,7 +547,7 @@ class Anime(Cog):
async with session.post(url, data=data, headers=self.headers) as resp: async with session.post(url, data=data, headers=self.headers) as resp:
# Store waifu's in dict when request is successful, else send an error # Store waifu's in dict when request is successful, else send an error
if resp.status == 200: if resp.status == 200:
waifu_dict = await resp.json() api_data = await resp.json()
# Send error if something went wrong internally/while grabbing data from API # Send error if something went wrong internally/while grabbing data from API
else: else:
@ -556,20 +556,16 @@ class Anime(Cog):
# Close session # Close session
await session.close() await session.close()
# As long waifu's were returned from the GET request # As long as data is returned
# Store waifus in a dict # Store all data from the api in dict
if len(waifu_dict["data"]) > 0: if len(api_data["data"]) > 0:
for waifu in waifu_dict["data"]: for item in api_data["data"]:
# Only store "Waifu's" and "Husbando's"
if waifu["type"] in ["Waifu", "Husbando"]: # Don't bother storing Hentai's or Games (Not yet until I figure out what data they send)
anime_or_waifu[waifu["name"]] = {} if item["type"] in ["Waifu", "Husbando", "TV", "ONA", "OVA"]:
for value in waifu: anime_or_waifu[item["name"]] = {}
store_dict(anime_or_waifu, waifu, value) for value in item:
store_dict(anime_or_waifu, item, value)
elif waifu["type"] in ["TV", "ONA", "OVA"]:
anime_or_waifu[waifu["name"]] = {}
for value in waifu:
store_dict(anime_or_waifu, waifu, value)
# When no waifu has been retrieved, send error message to the user # When no waifu has been retrieved, send error message to the user
else: else:

Loading…
Cancel
Save