diff options
Diffstat (limited to 'data/rbot/plugins/imdb.rb')
-rw-r--r-- | data/rbot/plugins/imdb.rb | 32 |
1 files changed, 27 insertions, 5 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 |