]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - data/rbot/plugins/imdb.rb
Simplify support for using "auto" to detect source language
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / imdb.rb
index 5ed5a66fc665422f6f73a5ceb5a6c6c5ee0b1e01..33e13b637295e8d5535337ed33e8b21897bdf3b5 100644 (file)
@@ -99,7 +99,7 @@ class Imdb
   end
 
   def grab_info(info, body)
-    /<div class="info">\s+<h5>#{info}:<\/h5>\s+(.*?)<\/div>/mi.match(body)[1] rescue nil
+    /<div (?:id="\S+-info" )?class="info">\s+<h5>#{info}:<\/h5>\s+(.*?)<\/div>/mi.match(body)[1] rescue nil
   end
 
   def fix_article(org_tit)
@@ -153,7 +153,7 @@ class Imdb
         country = data.ircify_html.gsub(' / ','/')
       end
 
-      info << [title, "(#{country}, #{date})", extra, dir ? "[#{dir}]" : nil, opts[:nourl] ? nil : ": http://us.imdb.com#{sr}"].compact.join(" ")
+      info << [title, "(#{country}, #{date})", extra, dir ? "[#{dir}]" : nil, opts[:nourl] ? nil : ": http://www.imdb.com#{sr}"].compact.join(" ")
 
       return info if opts[:title_only]
 
@@ -165,7 +165,7 @@ class Imdb
       end
 
       ratings = "no votes"
-      m = /<b>([0-9.]+)\/10<\/b>\n?\r?\s+<small>\(<a href="ratings">([0-9,]+) votes?<\/a>\)<\/small>/.match(resp.body)
+      m = /<b>([0-9.]+)\/10<\/b>\n?\r?\s+[^<]+<a href="ratings"[^>]+>([0-9,]+) votes?<\/a>/.match(resp.body)
       if m
         ratings = "#{m[1]}/10 (#{m[2]} voters)"
       end
@@ -206,7 +206,7 @@ class Imdb
       name = m[1]
 
       info << "#{name}"
-      info << " : http://us.imdb.com#{sr}" unless opts[:nourl]
+      info.last << " : http://www.imdb.com#{sr}" unless opts[:nourl]
 
       return info if opts[:name_only]
 
@@ -469,7 +469,7 @@ class ImdbPlugin < Plugin
   end
 
   # Find the movies with a participation of :who in the year :year
-  # TODO: allow year to be either a year or a decade ('[in the] 1960s') 
+  # TODO: allow year to be either a year or a decade ('[in the] 1960s')
   #
   def movies(m, params)
     who = params[:who].to_s