diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2008-03-19 01:37:27 +0100 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2008-03-19 14:49:49 +0100 |
commit | 7875312e3b5d7042efba931e8aa237be9c5b9313 (patch) | |
tree | e3ce9d373706b107c05051cee20aa5e91ddad05f /data/rbot | |
parent | d8ab842011a467196943cf2aa047fa956af247c5 (diff) |
imdb plugin: imdb_filter for titles
Diffstat (limited to 'data/rbot')
-rw-r--r-- | data/rbot/plugins/imdb.rb | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/data/rbot/plugins/imdb.rb b/data/rbot/plugins/imdb.rb index 82afd94a..94e4e571 100644 --- a/data/rbot/plugins/imdb.rb +++ b/data/rbot/plugins/imdb.rb @@ -153,7 +153,7 @@ class Imdb country = data.ircify_html.gsub(' / ','/') end - info << [title, "(#{country}, #{date})", extra, dir ? "[#{dir}]" : nil, ": http://us.imdb.com#{sr}"].compact.join(" ") + info << [title, "(#{country}, #{date})", extra, dir ? "[#{dir}]" : nil, opts[:nourl] ? nil : ": http://us.imdb.com#{sr}"].compact.join(" ") return info if opts[:title_only] @@ -405,9 +405,27 @@ class ImdbPlugin < Plugin attr_reader :i + TITLE_URL = %r{^http://(?:[^.]+\.)?imdb.com(/title/tt\d+/)} + def imdb_filter(s) + loc = Utils.check_location(s, TITLE_URL) + if loc + sr = loc.first.match(TITLE_URL)[1] + extra = $2 + res = i.info_title(sr, :nourl => true, :characters => (extra == 'fullcredits')) + debug res + if res + return {:title => res.first, :content => res.last} + else + return nil + end + end + return nil + end + def initialize super @i = Imdb.new(@bot) + @bot.register_filter(:imdb, :htmlinfo) { |s| imdb_filter(s) } end # Find a person or movie on IMDB. A :type (name/title, default both) can be |