Update for derpibooru API update
This commit is contained in:
parent
06ecc7bcc3
commit
a7298cf4cf
|
@ -171,7 +171,7 @@ class Images(commands.Cog):
|
||||||
RESULT: A picture of Rainbow Dash!"""
|
RESULT: A picture of Rainbow Dash!"""
|
||||||
|
|
||||||
if len(search) > 0:
|
if len(search) > 0:
|
||||||
url = 'https://derpibooru.org/search.json'
|
url = 'https://derpibooru.org/api/v1/json/search/images'
|
||||||
|
|
||||||
# Ensure a filter was not provided, as we either want to use our own, or none (for safe pics)
|
# Ensure a filter was not provided, as we either want to use our own, or none (for safe pics)
|
||||||
query = ' '.join(value for value in search if not re.search('&?filter_id=[0-9]+', value))
|
query = ' '.join(value for value in search if not re.search('&?filter_id=[0-9]+', value))
|
||||||
|
@ -196,7 +196,7 @@ class Images(commands.Cog):
|
||||||
if data is None:
|
if data is None:
|
||||||
await ctx.send("Sorry but I failed to connect to Derpibooru!")
|
await ctx.send("Sorry but I failed to connect to Derpibooru!")
|
||||||
return
|
return
|
||||||
results = data['search']
|
results = data['images']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
await ctx.send("No results with that search term, {0}!".format(ctx.message.author.mention))
|
await ctx.send("No results with that search term, {0}!".format(ctx.message.author.mention))
|
||||||
return
|
return
|
||||||
|
@ -213,12 +213,12 @@ class Images(commands.Cog):
|
||||||
await ctx.send("Sorry but I failed to connect to Derpibooru!")
|
await ctx.send("Sorry but I failed to connect to Derpibooru!")
|
||||||
return
|
return
|
||||||
# Now get the results again
|
# Now get the results again
|
||||||
results = data['search']
|
results = data['images']
|
||||||
|
|
||||||
# Get the image link from the now random page'd and random result from that page
|
# Get the image link from the now random page'd and random result from that page
|
||||||
index = random.SystemRandom().randint(0, len(results) - 1)
|
index = random.SystemRandom().randint(0, len(results) - 1)
|
||||||
# image_link = 'https://derpibooru.org/{}'.format(results[index]['id'])
|
# image_link = 'https://derpibooru.org/{}'.format(results[index]['id'])
|
||||||
image_link = 'https:{}'.format(results[index]['image'])
|
image_link = results[index]['view_url']
|
||||||
else:
|
else:
|
||||||
await ctx.send("No results with that search term, {0}!".format(ctx.message.author.mention))
|
await ctx.send("No results with that search term, {0}!".format(ctx.message.author.mention))
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue