From 22b15b5e5f58dda58ded89d98cda10869cf67590 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Thu, 18 Oct 2012 11:15:51 +1300 Subject: [PATCH] Fixed the 'movie not found' message, you can now look up IMDB movie ids --- plugins/imdb.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/plugins/imdb.py b/plugins/imdb.py index 4d9bac7..d0628a1 100755 --- a/plugins/imdb.py +++ b/plugins/imdb.py @@ -1,16 +1,24 @@ # IMDb lookup plugin by Ghetto Wizard (2011). from util import hook, http +import re + +id_re = re.compile("tt\d+") @hook.command def imdb(inp): "imdb -- Gets information about from IMDb." - content = http.get_json("http://www.omdbapi.com/", t=inp) + strip = inp.strip() - if content['Response'] == 'Movie Not Found': - return 'movie not found' + if id_re.match(strip): + content = http.get_json("http://www.omdbapi.com/", i=strip) + else: + content = http.get_json("http://www.omdbapi.com/", t=strip) + + if content['Error'] == 'Movie not found!': + return 'Movie not found!' elif content['Response'] == 'True': content['URL'] = 'http://www.imdb.com/title/%(imdbID)s' % content @@ -23,4 +31,4 @@ def imdb(inp): out += ' %(URL)s' return out % content else: - return 'unknown error' + return 'Unknown error.'