🕷 zenspider.com

by ryan davis



sitemap
Looking for the Ruby Quickref?

STIW3 - IMDB's Top 20 Worst Actors

Published 2007-03-29 @ 13:01

Tagged ruby, toys

Episode 3 of the “Stupid Thing I Wrote”, figure out the worst actors on IMDB:

  1. 194 Paris Hilton (The Hillz, Bottoms Up)
  2. 183 Jim Varney (Snowboard Academy, 3 Ninjas: High Noon at Mega Mountain)
  3. 177 Hulk Hogan (Santa with Muscles, 3 Ninjas: High Noon at Mega Mountain)
  4. 174 Kal Penn (Son of the Mask, Epic Movie, Van Wilder 2: The Rise of Taj)
  5. 171 Clint Howard (Santa with Muscles, House of the Dead)
  6. 168 Jack McGee (Chairman of the Board, Cool as Ice)
  7. 164 Corey Haim (Snowboard Academy, Last Resort)
  8. 162 Deezer D (In the Mix, Cool as Ice)
  9. 159 Gary Anthony Sturgis (Daddy’s Little Girls, Pride)
  10. 157 Myles Fitzgerald (SuperBabies: Baby Geniuses 2, Baby Geniuses) / Gerry Fitzgerald (SuperBabies: Baby Geniuses 2, Baby Geniuses) / Leo Fitzgerald (SuperBabies: Baby Geniuses 2, Baby Geniuses) / Will Sanderson (House of the Dead, Alone in the Dark, BloodRayne)
  11. 153 Gabrielle Union (Daddy’s Little Girls, The Honeymooners)
  12. 151 Terrence Howard (Glitter, Pride)
  13. 150 Valarie Pettiford (Glitter, Stomp the Yard) / Jack Warden (Chairman of the Board, Ed) / Mickey Knox (Ghosts Can’t Do It, Bolero, Ghoulies II)
  14. 142 Kevin Smith (Bottoms Up, Doogal)
  15. 138 Jürgen Prochnow (House of the Dead, Primeval)
  16. 136 Meagan Good (Stomp the Yard, You Got Served)
  17. 127 Bo Derek (Ghosts Can’t Do It, Bolero)
  18. 123 Victor Wong (3 Ninjas: High Noon at Mega Mountain, Shanghai Surprise)
  19. 116 Jon Polito (The Honeymooners, Happily N’Ever After)
  20. 110 Billy Zane (Going Overboard, BloodRayne)

code after the cut.

It makes me sad that “You Got Served” is no longer the worst movie on IMDB. (I’ll release webcache later, you can get this working just fine without caching–not that you want to)

  require 'rubygems'
  require 'hpricot'
  require 'webcache'
  
  $max = (ARGV.shift || 10).to_i    class IMDB < WebCache
    def initialize
      super ".imdbcache", "ryand-ruby@zenspider.com Ruby/#{RUBY_VERSION}", 999
      @base = "http://www.imdb.com"
    end
  
    def bottom
      c = cache("imdb", "bottom") do
        get File.join(@base, "chart/bottom")
      end
  
      doc = Hpricot(c)
  
      (doc/"a").select { |a| a.attributes['href'] =~ /title.tt/ }.map { |a|
        [a.attributes['href'], a.children.first.content]
      }
    end
  
    def movie(url)
      n = url[/\d+/]
      c = cache("movie", n) do
        t = get File.join(@base, url)
        sleep 1
        t
      end
  
      fragment = c[/^.*(?:Cast overview|[Cc]redited cast).*fullcredits.*$/]
  
      begin
        doc = Hpricot(fragment)
      rescue => e
        p e.message, fragment
        puts c
        exit 1
      end
  
      (doc/"a").select { |a| a.attributes['href'] =~ /name.nm/ and Hpricot::Text === a.children.first }.map { |a|
        [a.attributes['href'], a.children.first.content]
      }
    end
  
    def worst
      movie_names = {}
      actor_names = {}
      movies = Hash.new { |h,k| h[k] = [] }
      scores = Hash.new(0)
  
      bottom.each_with_index do |(movie_url, movie_name), i|
        movie_names[movie_url] = movie_name
        score = 100 - i
        m = movie(movie_url)
        m.each do |actor_url, actor_name|
          movies[actor_url] << movie_url
          actor_names[actor_url] = actor_name unless actor_names.has_key? actor_url
          scores[actor_url] += score
        end
      end
  
      by_scores = Hash.new { |h,k| h[k] = [] }
  
      scores.each do |actor_url, score|
        s = "%s (%s)" % [actor_names[actor_url], movies[actor_url].map { |url| movie_names[url]}.join(", ")]
        by_scores[score] << s
      end
  
      puts "Top #{$max} worst actors"
      puts
  
      by_scores.sort_by {|score,x| -score}.first($max).each_with_index do |(score, actors), i|
        n = i + 1
        puts "%2d) %3d %s" % [n, score, actors.join("\n        ")]
      end
    end
  end
  
  imdb = IMDB.new
  imdb.worst