From bbf28120c7975c1b5d464d35649d5a62c50bcd2f Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Wed, 4 Apr 2007 19:45:34 +0000 Subject: imdb plugin: show popular movies acted/directed when finding people --- data/rbot/plugins/imdb.rb | 32 +++++++++++++++++++++++++++----- data/rbot/plugins/url.rb | 4 ++-- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/data/rbot/plugins/imdb.rb b/data/rbot/plugins/imdb.rb index d8d4dad8..5615ac00 100644 --- a/data/rbot/plugins/imdb.rb +++ b/data/rbot/plugins/imdb.rb @@ -138,15 +138,37 @@ class Imdb death = "Death: #{data.ircify_html.gsub(/\s+more$/,'')}" end - awards = nil - data = grab_info("Awards", resp.body) - if data - awards = "Awards: #{data.ircify_html.gsub(/\s+more$/,'')}" + movies = {} + + filmorate = nil + begin + filmorate = @bot.httputil.get("http://us.imdb.com" + sr + "filmorate") + rescue Exception end + if filmorate + filmorate.scan(/
.*?([^<]+)<\/a>/)[1] rescue nil + # next unless what + next unless ['Actor', 'Director'].include?(what) + movies[what] = str.scan(/([^<]+)<\/a>/)[0..2].map { |tit| + Utils.decode_html_entities(tit) + } + } + end + debug movies.inspect + info = "#{name} : http://us.imdb.com#{sr}\n" info << [birth, death].compact.join('. ') << "\n" - info << awards if awards + unless movies.empty? + info << "Top Movies:: " + ar = [] + movies.keys.sort.each { |key| + ar << key.dup + ar.last << ": " + movies[key].join(', ') + } + info << ar.join('. ') + end return info end diff --git a/data/rbot/plugins/url.rb b/data/rbot/plugins/url.rb index 95ccb5d9..f3eb3a7f 100644 --- a/data/rbot/plugins/url.rb +++ b/data/rbot/plugins/url.rb @@ -60,9 +60,9 @@ class UrlPlugin < Plugin # in the first case we download the initial part and the parse it; in the second # case we only download as much as we need to find the title if @bot.config['url.first_par'] - first_par = Utils.ircify_first_html_par(body) - extra << "\n#{LINK_INFO} text: #{first_par}" unless first_par.empty? title = get_title_from_html(body) + first_par = Utils.ircify_first_html_par(body, :strip => title) + extra << "\n#{LINK_INFO} text: #{first_par}" unless first_par.empty? return "title: #{title}#{extra}" if title else title = get_title_from_html(body) -- cgit v1.2.3