summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2007-04-04 19:45:34 +0000
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2007-04-04 19:45:34 +0000
commitbbf28120c7975c1b5d464d35649d5a62c50bcd2f (patch)
tree1eec012df3a3e274966d8cd4ab4c108244940e07
parentb75b0d44bfc356b9f900edf7fb94de856adc2c96 (diff)
imdb plugin: show popular movies acted/directed when finding people
-rw-r--r--data/rbot/plugins/imdb.rb32
-rw-r--r--data/rbot/plugins/url.rb4
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(/<div class="filmo">.*?<a href="\/title.*?<\/div>/m) { |str|
+ what = str.match(/<a name="[^"]+">([^<]+)<\/a>/)[1] rescue nil
+ # next unless what
+ next unless ['Actor', 'Director'].include?(what)
+ movies[what] = str.scan(/<a href="\/title\/[^"]+">([^<]+)<\/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)