Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Trailer Poster #9

Merged
merged 1 commit into from

2 participants

@venkiwhite

Added new code to get trailer poster image. User can show this poster before playing trailer.

@maddox maddox merged commit d149c14 into maddox:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 28, 2011
  1. @venkiwhite
This page is out of date. Refresh to see the latest.
View
6 README.md
@@ -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
2  imdb_party.gemspec
@@ -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
4 lib/imdb_party/movie.rb
@@ -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
16 test/slate_test.rb
@@ -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
+
Something went wrong with that request. Please try again.