def imdb(message): # Method added by BananaWaffles.
msg = message.content.split()
if apis["MYAPIFILMS_TOKEN"] == "TOKENHERE":
await client.send_message(message.channel, "`This command wasn't configured properly. If you're the owner, edit json/apis.json`")
return False
if len(msg) > 1:
if len(msg[1]) > 1 and len([msg[1]]) < 20:
try:
msg.remove(msg[0])
msg = "+".join(msg)
search = "http://api.myapifilms.com/imdb/title?format=json&title=" + msg + "&token=" + apis["MYAPIFILMS_TOKEN"]
async with aiohttp.get(search) as r:
result = await r.json()
title = result['data']['movies'][0]['title']
year = result['data']['movies'][0]['year']
rating = result['data']['movies'][0]['rating']
url = result['data']['movies'][0]['urlIMDB']
msg = "Title: " + title + " | Released on: " + year + " | IMDB Rating: " + rating + ".\n" + url
await client.send_message(message.channel, msg)
except:
await client.send_message(message.channel, "`Error.`")
else:
await client.send_message(message.channel, "`Invalid search.`")
else:
await client.send_message(message.channel, "`" + settings["PREFIX"] + "imdb [text]`")
评论列表
文章目录