Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

update this gem so people don't use it

  • Loading branch information...
commit 58cad7f1ebdf1c198fbe8cf2445324c7f9b6c1ed 1 parent 622ea36
Jon Maddox authored
Showing with 171 additions and 189 deletions.
  1. +3 −21 README.textile
  2. +168 −168 test/imdb_test.rb
24 README.textile
View
@@ -1,24 +1,6 @@
h1. IMDB!
-h2. What?
+h2. DON'T USE THIS
-A simple ruby library to scrape IMDB
-
-h2. How?
-
-<pre>
- <code>
-movie = Imdb.find_movie_by_id('tt1099212')
-movie.title
-</code>
-=> "Twilight"
-
-</pre>
-
-It does more of course, just look at the source.
-
-h2. Installation
-
-gem install imdb
-
-gem hosted on Gemcutter
+This essentially uses screen scraping and is totally broken now that IMDB has new movie page layouts.
+Use this new gem: "http://github.com/maddox/imdb_party":http://github.com/maddox/imdb_party
336 test/imdb_test.rb
View
@@ -2,23 +2,23 @@
class ImdbTest < Test::Unit::TestCase
- context "Imdb" do
- should "have an imdb movie base url" do
- assert_equal "http://www.imdb.com/title/", Imdb::IMDB_MOVIE_BASE_URL
- end
- should "have an imdb search base url" do
- assert_equal "http://imdb.com/find?s=all&q=", Imdb::IMDB_SEARCH_BASE_URL
- end
- should "have a top 250 url" do
- assert_equal "http://www.imdb.com/chart/top", Imdb::IMDB_TOP_250_URL
- end
- should "have a top for decade base url" do
- assert_equal "http://www.imdb.com/chart/", Imdb::IMDB_TOP_BY_DECADE_BASE_URL
- end
- should "have an all time box office base url" do
- assert_equal "http://www.imdb.com/boxoffice/alltimegross", Imdb::IMDB_ALL_TIME_BOX_OFFICE_BASE_URL
- end
- end
+ # context "Imdb" do
+ # should "have an imdb movie base url" do
+ # assert_equal "http://www.imdb.com/title/", Imdb::IMDB_MOVIE_BASE_URL
+ # end
+ # should "have an imdb search base url" do
+ # assert_equal "http://imdb.com/find?s=all&q=", Imdb::IMDB_SEARCH_BASE_URL
+ # end
+ # should "have a top 250 url" do
+ # assert_equal "http://www.imdb.com/chart/top", Imdb::IMDB_TOP_250_URL
+ # end
+ # should "have a top for decade base url" do
+ # assert_equal "http://www.imdb.com/chart/", Imdb::IMDB_TOP_BY_DECADE_BASE_URL
+ # end
+ # should "have an all time box office base url" do
+ # assert_equal "http://www.imdb.com/boxoffice/alltimegross", Imdb::IMDB_ALL_TIME_BOX_OFFICE_BASE_URL
+ # end
+ # end
# context "when getting top250" do
# setup do
@@ -76,45 +76,45 @@ class ImdbTest < Test::Unit::TestCase
# end
# end
- context "when getting top by box office" do
- setup do
- @top_by_box_office = Imdb.all_time_us_box_office
- end
-
- should "return an array of results" do
- assert_equal Array, @top_by_box_office.class
- end
-
- context "the results" do
- setup do
- @result = @top_by_box_office.first
- end
-
- should "have an imdb_id" do
- assert_not_equal nil, @result[:imdb_id]
- end
-
- should "have a title" do
- assert_not_equal nil, @result[:title]
- end
-
- should "have a dollar amount" do
- assert_not_equal nil, @result[:dollar_amount]
- end
- end
-
- end
-
- context "when getting top by worldwide box office" do
- setup do
- @top_by_box_office = Imdb.all_time_worldwide_box_office
- end
-
- should "return an array of results" do
- assert_equal Array, @top_by_box_office.class
- end
-
- end
+ # context "when getting top by box office" do
+ # setup do
+ # @top_by_box_office = Imdb.all_time_us_box_office
+ # end
+ #
+ # should "return an array of results" do
+ # assert_equal Array, @top_by_box_office.class
+ # end
+ #
+ # context "the results" do
+ # setup do
+ # @result = @top_by_box_office.first
+ # end
+ #
+ # should "have an imdb_id" do
+ # assert_not_equal nil, @result[:imdb_id]
+ # end
+ #
+ # should "have a title" do
+ # assert_not_equal nil, @result[:title]
+ # end
+ #
+ # should "have a dollar amount" do
+ # assert_not_equal nil, @result[:dollar_amount]
+ # end
+ # end
+ #
+ # end
+ #
+ # context "when getting top by worldwide box office" do
+ # setup do
+ # @top_by_box_office = Imdb.all_time_worldwide_box_office
+ # end
+ #
+ # should "return an array of results" do
+ # assert_equal Array, @top_by_box_office.class
+ # end
+ #
+ # end
context "when searching" do
# context "for an ambiguous title" do
@@ -158,117 +158,117 @@ class ImdbTest < Test::Unit::TestCase
end
- # context "ImdbMovie" do
- # context "when first created" do
- # should "not have an imdb_id" do
- # movie = ImdbMovie.new
- # assert_nil movie.imdb_id
- # end
- # end
- #
- # context "after an Imdb.find_by_id returns it" do
- # setup do
- # @movie = Imdb.find_movie_by_id('tt0382932')
- # end
- #
- # should "have an imdb_id" do
- # assert_equal 'tt0382932', @movie.imdb_id
- # end
- #
- # should "have a title" do
- # assert_equal 'Ratatouille', @movie.title
- # end
- #
- # should "have a release date" do
- # assert_equal Date.new(2007, 06, 29), @movie.release_date
- # end
- #
- # should "have a G certification" do
- # assert_equal 'G', @movie.certification
- # end
- #
- # should "have a company" do
- # assert_equal 'co0017902', @movie.company.imdb_id
- # assert_equal 'Pixar Animation Studios', @movie.company.name
- # end
- #
- # should "have two directors" do
- # assert_equal 2, @movie.directors.length
- # assert_equal 'nm0083348', @movie.directors[0].imdb_id
- # assert_equal 'Brad Bird', @movie.directors[0].name
- # assert_equal '', @movie.directors[0].role
- #
- # assert_equal 'nm0684342', @movie.directors[1].imdb_id
- # assert_equal 'Jan Pinkava', @movie.directors[1].name
- # assert_equal 'co-director', @movie.directors[1].role
- # end
- #
- # should "have two writers" do
- # assert_equal 2, @movie.writers.length
- # assert_equal 'nm0083348', @movie.writers[0].imdb_id
- # assert_equal 'Brad Bird', @movie.writers[0].name
- # assert_equal 'screenplay', @movie.writers[0].role
- #
- # assert_equal 'nm0684342', @movie.writers[1].imdb_id
- # assert_equal 'Jan Pinkava', @movie.writers[1].name
- # assert_equal 'story', @movie.writers[1].role
- # end
- #
- # should "have 15 actors" do
- # assert_equal 15, @movie.actors.length
- # assert_equal 'nm0652663', @movie.actors[0].imdb_id
- # assert_equal 'Patton Oswalt', @movie.actors[0].name
- # assert_equal 'Remy (voice)', @movie.actors[0].role
- #
- # assert_equal 'nm0826039', @movie.actors[14].imdb_id
- # assert_equal 'Jake Steinfeld', @movie.actors[14].name
- # assert_equal 'Git (Lab Rat) (voice)', @movie.actors[14].role
- # end
- #
- # should "have four genres" do
- # assert_equal 4, @movie.genres.length
- # assert_equal 'Animation', @movie.genres[0].name
- # assert_equal 'Comedy', @movie.genres[1].name
- # assert_equal 'Family', @movie.genres[2].name
- # assert_equal 'Fantasy', @movie.genres[3].name
- # end
- #
- # should "have a tagline" do
- # assert_equal 'Dinner is served... Summer 2007', @movie.tagline
- # end
- #
- # should "have a rating" do
- # assert_match /\d.\d/, @movie.rating
- # end
- #
- # should "have a poster_url" do
- # assert_match /http:\/\/.*\.jpg/, @movie.poster_url
- # end
- #
- # should "have a runtime" do
- # assert_match /\d+ min/, @movie.runtime
- # end
- #
- # should "have a plot" do
- # assert_equal %{Remy is a young rat in the French countryside who arrives in Paris, only to find out that his cooking idol is dead. When he makes an unusual alliance with a restaurant's new garbage boy, the culinary and personal adventures begin despite Remy's family's skepticism and the rat-hating world of humans.}, @movie.plot
- # end
- #
- # should "return an empty array if writers is nil" do
- # @movie.writers = nil
- # assert_equal [], @movie.writers
- # end
- #
- # should "return an empty array if directors is nil" do
- # @movie.directors = nil
- # assert_equal [], @movie.directors
- # end
- #
- # should "return an empty array if genres is nil" do
- # @movie.genres = nil
- # assert_equal [], @movie.genres
- # end
- # end
- #
- # end
+ context "ImdbMovie" do
+ context "when first created" do
+ should "not have an imdb_id" do
+ movie = ImdbMovie.new
+ assert_nil movie.imdb_id
+ end
+ end
+
+ context "after an Imdb.find_by_id returns it" do
+ setup do
+ @movie = Imdb.find_movie_by_id('tt0382932')
+ end
+
+ should "have an imdb_id" do
+ assert_equal 'tt0382932', @movie.imdb_id
+ end
+
+ should "have a title" do
+ assert_equal 'Ratatouille', @movie.title
+ end
+
+ should "have a release date" do
+ assert_equal Date.new(2007, 06, 29), @movie.release_date
+ end
+
+ should "have a G certification" do
+ assert_equal 'G', @movie.certification
+ end
+
+ should "have a company" do
+ assert_equal 'co0017902', @movie.company.imdb_id
+ assert_equal 'Pixar Animation Studios', @movie.company.name
+ end
+
+ should "have two directors" do
+ assert_equal 2, @movie.directors.length
+ assert_equal 'nm0083348', @movie.directors[0].imdb_id
+ assert_equal 'Brad Bird', @movie.directors[0].name
+ assert_equal '', @movie.directors[0].role
+
+ assert_equal 'nm0684342', @movie.directors[1].imdb_id
+ assert_equal 'Jan Pinkava', @movie.directors[1].name
+ assert_equal 'co-director', @movie.directors[1].role
+ end
+
+ should "have two writers" do
+ assert_equal 2, @movie.writers.length
+ assert_equal 'nm0083348', @movie.writers[0].imdb_id
+ assert_equal 'Brad Bird', @movie.writers[0].name
+ assert_equal 'screenplay', @movie.writers[0].role
+
+ assert_equal 'nm0684342', @movie.writers[1].imdb_id
+ assert_equal 'Jan Pinkava', @movie.writers[1].name
+ assert_equal 'story', @movie.writers[1].role
+ end
+
+ should "have 15 actors" do
+ assert_equal 15, @movie.actors.length
+ assert_equal 'nm0652663', @movie.actors[0].imdb_id
+ assert_equal 'Patton Oswalt', @movie.actors[0].name
+ assert_equal 'Remy (voice)', @movie.actors[0].role
+
+ assert_equal 'nm0826039', @movie.actors[14].imdb_id
+ assert_equal 'Jake Steinfeld', @movie.actors[14].name
+ assert_equal 'Git (Lab Rat) (voice)', @movie.actors[14].role
+ end
+
+ should "have four genres" do
+ assert_equal 4, @movie.genres.length
+ assert_equal 'Animation', @movie.genres[0].name
+ assert_equal 'Comedy', @movie.genres[1].name
+ assert_equal 'Family', @movie.genres[2].name
+ assert_equal 'Fantasy', @movie.genres[3].name
+ end
+
+ should "have a tagline" do
+ assert_equal 'Dinner is served... Summer 2007', @movie.tagline
+ end
+
+ should "have a rating" do
+ assert_match /\d.\d/, @movie.rating
+ end
+
+ should "have a poster_url" do
+ assert_match /http:\/\/.*\.jpg/, @movie.poster_url
+ end
+
+ should "have a runtime" do
+ assert_match /\d+ min/, @movie.runtime
+ end
+
+ should "have a plot" do
+ assert_equal %{Remy is a young rat in the French countryside who arrives in Paris, only to find out that his cooking idol is dead. When he makes an unusual alliance with a restaurant's new garbage boy, the culinary and personal adventures begin despite Remy's family's skepticism and the rat-hating world of humans.}, @movie.plot
+ end
+
+ should "return an empty array if writers is nil" do
+ @movie.writers = nil
+ assert_equal [], @movie.writers
+ end
+
+ should "return an empty array if directors is nil" do
+ @movie.directors = nil
+ assert_equal [], @movie.directors
+ end
+
+ should "return an empty array if genres is nil" do
+ @movie.genres = nil
+ assert_equal [], @movie.genres
+ end
+ end
+
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.