Atheuz

Untitled

May 11th, 2011 (edited)
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.01 KB | None | 0 0
  1. # IMDb lookup plugin
  2.  
  3. from util import hook, http
  4.  
  5. def out(*args):
  6.     d = args[0]
  7.     s = ""
  8.     if d["Title"] != "N/A":
  9.         s += "\x02%(Title)s\x02 "
  10.     if d["Year"] != "N/A":
  11.         s += "(%(Year)s) "
  12.     if d["Genre"] != "N/A":
  13.         s += "(%(Genre)s): "
  14.     if d["Plot"] != "N/A":
  15.         s += "%(Plot)s "
  16.     if d["Runtime"] != "N/A":
  17.         s += "\x02%(Runtime)s\x02. "
  18.     if d["Rating"] != "N/A" and d["Votes"] != "N/A":
  19.         s += "\x02%(Rating)s/10\x02 with \x02%(Votes)s\x02 votes. "
  20.     if d["URL"] != "N/A":
  21.         s += "%(URL)s"
  22.     return s % d
  23.  
  24. @hook.command
  25. def imdb(inp):
  26.     '''.imdb <movie> -- gets information about <movie> from IMDb'''
  27.  
  28.     content = http.get_json("http://www.imdbapi.com/", t=inp)
  29.  
  30.     if content['Response'] == 'Movie Not Found':
  31.         return 'movie not found'
  32.     elif content['Response'] == 'True':
  33.         content['URL'] = 'http://www.imdb.com/title/%(ID)s' % content
  34.         return out(content)
  35.     else:
  36.         return 'unknown error'
Add Comment
Please, Sign In to add comment