Trailer Poster #9

Merged
merged 1 commit into from Jul 12, 2012
View
@@ -20,6 +20,12 @@
movie.rating => 8.1
movie.certification => "PG-13"
+### Get a movie trailer poster
+
+ movie = imdb.find_movie_by_id("tt1210166")
+
+ movie.slate_url => "http://ia.media-imdb.com/images/M/MV5BODM1NDMxMTI3M15BMl5BanBnXkFtZTcwMDAzODY1Ng@@._V1_.jpg"
+
### Find the top 250 movies of all time
imdb.top_250 => [{:title => "Shawshank Redemption", :year => "1994", :imdb_id => "tt0111161"}, {:title => "The Godfather", ...}]
View
@@ -32,6 +32,7 @@ Gem::Specification.new do |s|
"test/movie_test.rb",
"test/person_test.rb",
"test/search_test.rb",
+ "test/slate_test.rb",
"test/test_helper.rb"
]
s.homepage = %q{http://github.com/maddox/imdb_party}
@@ -43,6 +44,7 @@ Gem::Specification.new do |s|
"test/movie_test.rb",
"test/person_test.rb",
"test/search_test.rb",
+ "test/slate_test.rb",
"test/test_helper.rb"
]
View
@@ -1,6 +1,6 @@
module ImdbParty
class Movie
- attr_accessor :imdb_id, :title, :directors, :writers, :tagline, :company, :plot, :runtime, :rating, :poster_url, :release_date, :certification, :genres, :actors, :trailers
+ attr_accessor :imdb_id, :title, :directors, :writers, :tagline, :company, :plot, :runtime, :rating, :poster_url, :release_date, :certification, :genres, :actors, :trailers, :slate_url
def initialize(options={})
@imdb_id = options["tconst"]
@@ -13,6 +13,8 @@ def initialize(options={})
@release_date = options["release_date"]["normal"] if options["release_date"] && options["release_date"]["normal"]
@certification = options["certificate"]["certificate"] if options["certificate"] && options["certificate"]["certificate"]
@genres = options["genres"] || []
+ # parse trailer poster
+ @slate_url = options["trailer"]["slates"][0]["url"] if(options["trailer"] && options["trailer"]["slates"] && options["trailer"]["slates"][0])
# parse directors
@directors = options["directors_summary"] ? options["directors_summary"].map { |d| Person.new(d) } : []
View
@@ -0,0 +1,16 @@
+require 'test_helper'
+
+class SlateTest < Test::Unit::TestCase
+ context "a slate" do
+ setup do
+ @imdb = ImdbParty::Imdb.new
+ @movie = @imdb.find_movie_by_id("tt1210166")
+ end
+
+ should "have a slate_url" do
+ assert_match /http:\/\/ia.media-imdb.com\/images\/.*/, @movie.slate_url
+ end
+
+ end
+end
+