Switching to ID so that the dicts are truly unique

pull/9/head
sgoudham 4 years ago
parent f22b41b5d5
commit feae21147d

@ -49,7 +49,7 @@ def store_in_dict(_dict, api):
# Store all the shows with the name as the key # Store all the shows with the name as the key
for item in api: for item in api:
_dict[item["name"]] = {} _dict[item["id"]] = {}
for value in item: for value in item:
store_dict(_dict, item, value) store_dict(_dict, item, value)
@ -57,7 +57,7 @@ def store_in_dict(_dict, api):
def store_dict(dict_, key, value): def store_dict(dict_, key, value):
"""Method to store waifu's in the new dict""" """Method to store waifu's in the new dict"""
dict_[key["name"]][value] = key[value] dict_[key["id"]][value] = key[value]
async def get_from_api(self, ctx, url): async def get_from_api(self, ctx, url):
@ -102,7 +102,7 @@ async def post_from_api(self, i, ctx, term, _dict, url):
# Store all data from the api in dict # Store all data from the api in dict
if len(api_data["data"]) > 1: if len(api_data["data"]) > 1:
for item in api_data["data"]: for item in api_data["data"]:
_dict[item["name"]] = {} _dict[item["id"]] = {}
for value in item: for value in item:
store_dict(_dict, item, value) store_dict(_dict, item, value)
@ -223,6 +223,7 @@ async def detailed_waifu_embed(self, waifu, author, ctx):
# Get all the data to be displayed in the embed # Get all the data to be displayed in the embed
name = waifu["name"] name = waifu["name"]
_type = waifu["type"]
waifu_id = waifu["id"] waifu_id = waifu["id"]
url = waifu["url"] url = waifu["url"]
picture = waifu["display_picture"] picture = waifu["display_picture"]
@ -281,7 +282,7 @@ async def detailed_waifu_embed(self, waifu, author, ctx):
# Only using image if it can be displayed, else display 404 image # Only using image if it can be displayed, else display 404 image
picture_url = picture if picture.endswith((".jpeg", ".png", ".jpg")) else not_found picture_url = picture if picture.endswith((".jpeg", ".png", ".jpg")) else not_found
# Different titles depending on if author was given or not # Different titles depending on if author was given or not
title = f"True Love | {name}" if author else f"Detailed Waifu | {name}" title = f"True Love | {name}" if author else f"Detailed {_type} | {name}"
detailed = Embed(title=title, description=desc, detailed = Embed(title=title, description=desc,
colour=self.bot.random_colour(), colour=self.bot.random_colour(),
@ -502,7 +503,7 @@ class Anime(Cog):
for item in waifus: for item in waifus:
# Don't bother storing Hentai's or Games (Not yet until I figure out what data they send) # Don't bother storing Hentai's or Games (Not yet until I figure out what data they send)
if item["type"] in ["Waifu", "Husbando"]: if item["type"] in ["Waifu", "Husbando"]:
anime_waifus[item["name"]] = {} anime_waifus[item["id"]] = {}
for value in item: for value in item:
store_dict(anime_waifus, item, value) store_dict(anime_waifus, item, value)

Loading…
Cancel
Save