summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/imdb_search.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/modules/imdb_search.py b/modules/imdb_search.py
new file mode 100644
index 0000000..ff1a000
--- /dev/null
+++ b/modules/imdb_search.py
@@ -0,0 +1,28 @@
+info = {
+ 'author': 'Jon Bergli Heier',
+ 'title': 'IMDB',
+ 'description': 'IMDB search',
+}
+
+import imdb
+
+class Module:
+ def __init__(self, bot):
+ self.irc = bot
+ self.irc.register_keyword('!imdb', self)
+ self.ia = imdb.IMDb()
+
+ def keyword(self, nick, channel, kw, msg):
+ target = channel if not channel == self.irc.nickname else nick.split('!')[0]
+ args = msg.split()
+ if len(args) == 0:
+ self.irc.msg(target, 'Usage: !imdb search')
+ return
+ results = self.ia.search_movie(' '.join(args))
+ if len(results):
+ m = results[0]
+ self.ia.update(m)
+ s = u'\002%s\002 (%d) rated %.1f | %s' % (m['title'], m['year'], m['rating'], self.ia.get_imdbURL(m))
+ self.irc.msg(target, s.encode('utf-8'))
+ else:
+ self.irc.msg(target, 'imdb: No results.')