From edb0f8ac2c9b6589ac181fbb08978b1785c44c6d Mon Sep 17 00:00:00 2001 From: MahxieNoodle Date: Mon, 4 Nov 2019 20:56:41 -0700 Subject: [PATCH] Change how Horses and Snakes are accessed (#25) * Update Animal Image Fetch 1/4 * Animal Image Fetch 2/4 * Requested changes for Animal Image Fetch 3/4 --- cogs/images.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/cogs/images.py b/cogs/images.py index 901e5d9..120ad5b 100644 --- a/cogs/images.py +++ b/cogs/images.py @@ -54,17 +54,19 @@ class Images(commands.Cog): EXAMPLE: !snek RESULT: A beautiful picture of a snek o3o""" - result = await utils.request("http://hrsendl.com/snake") - if result is None: + data = await utils.request("http://hrsendl.com/api/snake") + + if data is None: await ctx.send("I couldn't connect! Sorry no snakes right now ;w;") return - filename = result.get('image', None) + result = data['data'] + filename = result.get('file_url_size_large', None) if filename is None: await ctx.send("I couldn't connect! Sorry no snakes right now ;w;") return image = await utils.download_image(filename) - filename = re.search('.*/snakes/(.*)', filename).group(1) + filename = re.search('.*/optimized/large/(.*)', filename).group(1) f = discord.File(image, filename=filename) await ctx.send(file=f) @@ -75,17 +77,19 @@ class Images(commands.Cog): EXAMPLE: !horse RESULT: A beautiful picture of a horse o3o""" - result = await utils.request("http://hrsendl.com/horse") - if result is None: + data = await utils.request("http://hrsendl.com/api/horse") + + if data is None: await ctx.send("I couldn't connect! Sorry no horses right now ;w;") return - filename = result.get('image', None) + result = data['data'] + filename = result.get('file_url_size_large', None) if filename is None: await ctx.send("I couldn't connect! Sorry no horses right now ;w;") return image = await utils.download_image(filename) - filename = re.search('.*/horses/(.*)', filename).group(1) + filename = re.search('.*/optimized/large/(.*)', filename).group(1) f = discord.File(image, filename=filename) await ctx.send(file=f)