Sha256: c02d10a37172cc4789b37ee43cfbf6d9d61410a61902e9567109626d74d1f776

Contents?: true

Size: 757 Bytes

Versions: 1

Compression:

Stored size: 757 Bytes

Contents

require 'imdb'

module Imdb
  class Search < MovieList

    def self.query(query)
      open("http://anonymouse.org/cgi-bin/anon-www.cgi/http://akas.imdb.com/find?q=#{CGI::escape(query)}&s=tt")
    end

    def parse_movie
      id                 = document.at("head/link[@rel='canonical']")['href'][/\d+/]
      title              = document.at("h1").innerHTML.imdb_strip_tags.gsub("\n", " ").strip.imdb_unescape_html
      [Imdb::Movie.new(id, title)]
    end

    def parse_movies
      document.search("a[@href^='http://anonymouse.org/cgi-bin/anon-www.cgi/http://akas.imdb.com/title/tt']").each do |pm|
        pm["href"] = pm["href"].gsub("http://anonymouse.org/cgi-bin/anon-www.cgi/http://akas.imdb.com", "")
      end
      super
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
unified_db-0.2.7 lib/extensions/imdb.rb