|
|
@ -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"]:
|
|
|
|
|
|
|
|
anime_or_waifu[waifu["name"]] = {}
|
|
|
|
|
|
|
|
for value in waifu:
|
|
|
|
|
|
|
|
store_dict(anime_or_waifu, waifu, value)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elif waifu["type"] in ["TV", "ONA", "OVA"]:
|
|
|
|
# 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)
|
|
|
|
|
|
|
|
|
|
|
|
# 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:
|
|
|
|