Added imdb id support as a fallback to imdb title checkout feature.
This commit is contained in:
parent
0a96627d6a
commit
17c29e386c
@ -25,9 +25,13 @@ def cmd_imdb(msg):
|
|||||||
data = json.loads(response.read().decode())
|
data = json.loads(response.read().decode())
|
||||||
|
|
||||||
if "Error" in data:
|
if "Error" in data:
|
||||||
raise IRCException(data["Error"])
|
url = "http://www.omdbapi.com/?i=%s" % urllib.parse.quote(' '.join(msg.cmds[1:]))
|
||||||
|
response = urllib.request.urlopen(url)
|
||||||
|
data = json.loads(response.read().decode())
|
||||||
|
if "Error" in data:
|
||||||
|
raise IRCException(data["Error"])
|
||||||
|
|
||||||
elif "Response" in data and data["Response"] == "True":
|
if "Response" in data and data["Response"] == "True":
|
||||||
res = Response(msg.sender, channel=msg.channel,
|
res = Response(msg.sender, channel=msg.channel,
|
||||||
title="%s (%s)" % (data['Title'], data['Year']),
|
title="%s (%s)" % (data['Title'], data['Year']),
|
||||||
nomore="No more information, more at http://www.imdb.com/title/%s" % data['imdbID'])
|
nomore="No more information, more at http://www.imdb.com/title/%s" % data['imdbID'])
|
||||||
|
Loading…
Reference in New Issue
Block a user