]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
imdb plugin: again fixes outdated ratings pattern
authorMatthias -apoc- Hecker <apoc@sixserv.org>
Mon, 26 Sep 2011 12:44:25 +0000 (14:44 +0200)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Mon, 26 Sep 2011 12:57:38 +0000 (14:57 +0200)
data/rbot/plugins/imdb.rb

index 05333dcce52d9acef1efdfc85efed4f8f75fe031..0f4b8c809e9124ac0fa1557ae0e5590d5bbe6d53 100644 (file)
@@ -175,9 +175,13 @@ class Imdb
       end
 
       ratings = "no votes"
-      m = resp.body.match(/Users rated this ([0-9.]+)\/10 \(([0-9,]+) votes\)/m)
-      if m
-        ratings = "#{m[1]}/10 (#{m[2]} voters)"
+      # parse imdb rating value:
+      if resp.body.match(/itemprop="ratingValue">([^<]+)</)
+        ratings = "#{$1}/10"
+      end
+      # parse imdb rating count:
+      if resp.body.match(/itemprop="ratingCount">([^<]+)</)
+        ratings += " (#{$1} voters)"
       end
 
       genre = Array.new