Merge pull request #62 from nbr23/v3.4

Added imdb id support as a fallback to imdb title checkout feature.
This commit is contained in:
nemunaire 2014-08-20 18:03:00 +02:00
commit 5559ae20d9

View File

@ -25,9 +25,13 @@ def cmd_imdb(msg):
data = json.loads(response.read().decode())
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,
title="%s (%s)" % (data['Title'], data['Year']),
nomore="No more information, more at http://www.imdb.com/title/%s" % data['imdbID'])