Skip to content

Commit

Permalink
Updating readme and adding feature
Browse files Browse the repository at this point in the history
  • Loading branch information
tmobaird committed Feb 14, 2016
1 parent 2ad8573 commit e4a3175
Show file tree
Hide file tree
Showing 3 changed files with 121 additions and 75 deletions.
161 changes: 86 additions & 75 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,12 @@ guidebox_movie.search_by_db_id(11, "themoviedb")
guidebox_movie.show_information("star wars a new hope")
# => {"id"=>55413, "title"=>"Star Wars: Episode IV: A New Hope", "release_year"=>1977, "themoviedb"=>11, "alternate_titles"=>["Star Wars", "Star Wars Episode IV - A New Hope", "Star Wars Episode 4 - A New Hope", "Star Wars Episode IV", "Star Wars 4", "Star Wars: Episode IV - A New Hope - Despecialized Edition", "Star Wars Episode IV: A New Hope", "Star Wars: Episode IV - A New Hope", "Star Wars: A New Hope", "Star Wars: A New Hope (Bonus Features)"], "imdb"=>"tt0076759", "pre_order"=>false, "release_date"=>"1977-05-25", "rating"=>"PG", "rottentomatoes"=>11292, "freebase"=>"/m/0dtfn", "wikipedia_id"=>52549, "metacritic"=>"http://www.metacritic.com/movie/star-wars-episode-iv---a-new-hope", "common_sense_media"=>nil, "overview"=>"Princess Leia is captured and held hostage by the evil Imperial forces in their effort to take over the galactic Empire. Venturesome Luke Skywalker and dashing captain Han Solo team together with the loveable robot duo R2-D2 and C-3PO to rescue the beautiful princess and restore peace and justice in the Empire.", ...}

guidebox_movie.posters("star wars a new hope")
# => [{"large"=>{"url"=>"http://static-api.guidebox.com/022615/thumbnails_movies/-alt--55413-2929921416-5712237544-4512474872-large-400x570-alt-.jpg", "width"=>400, "height"=>570}, ...]

guidebox_movie.thumbnail_images("star wars a new hope")
# => [{"xlarge"=>{"url"=>"http://static-api.guidebox.com/012915/movies/thumbnails/55413-4649667824-932900156-9715580251-608x342.jpg", "width"=>608, "height"=>342}, "large"=>{"url"=>"http://static-api.guidebox.com/012915/movies/thumbnails/55413-4649667824-932900156-9715580251-448x252.jpg", "width"=>448, "height"=>252}, ...]

guidebox_movie.banner_images("star wars a new hope")
# => [{"xlarge"=>{"url"=>"http://static-api.guidebox.com/012915/movies/banners/55413-9158895025-3035124387-2547398284-1300x240.jpg", "width"=>1300, "height"=>240}, "large"=>{"url"=>"http://static-api.guidebox.com/012915/movies/banners/55413-9158895025-3035124387-2547398284-1000x185.jpg", "width"=>1000, "height"=>185}, ...]

guidebox_movie.background_images("star wars a new hope")
# => [{"original"=>{"url"=>"http://static-api.guidebox.com/012915/movies/backgrounds/55413-83836050721-144034282636-0.jpg", "width"=>1920, "height"=>1080}, "original_width"=>1920, "original_height"=>1080, "image_rating"=>0}, {"original"=>{"url"=>"http://static-api.guidebox.com/012915/movies/backgrounds/55413-206143594668-179262854890-0.jpg", "width"=>1920, "height"=>1080}, "original_width"=>1920, "original_height"=>1080, "image_rating"=>0}, {"original"=>{"url"=>"http://static-api.guidebox.com/012915/movies/backgrounds/55413-187622151929-44181177682-0.jpg", "width"=>1920, "height"=>1080}, "original_width"=>1920, "original_height"=>1080, "image_rating"=>0}]

guidebox_movie.fetch_movie("star wars a new hope")
# => <Movie>

guidebox_movie.fetch_movie_by_db_id("tt0076759", "imdb")
# => <Movie>
# The first parameter is the external database id (if imdb the id should be a string, if themoviedb it should be an integer)
```

#### Accessbile Movie Attributes
Expand All @@ -91,7 +83,7 @@ guidebox_movie.fetch_movie("star wars a new hope")
:rottentomatoes, :alternate_titles, :freebase, :wikipedia_id, :metacritic_link, :overview, :genres, :tags, :facebook_link,
:web_trailers, :ios_trailers, :android_trailers, :free_web_sources, :free_ios_sources, :free_android_sources, :tv_everywhere_web_sources,
:tv_everywhere_ios_sources, :tv_everywhere_android_sources, :subscription_web_sources, :purchase_web_sources, :purchase_ios_sources,
:purchase_android_sources
:purchase_android_sources, :posters, :backgrounds, :banners, :thumbnails
```
These can be easily accessed as follows:
```ruby
Expand All @@ -108,6 +100,36 @@ movie.cast
# => [{"id"=>300791, "name"=>"Mark Hamill", "character_name"=>"Luke Skywalker"}, {"id"=>212668, "name"=>"Harrison Ford", "character_name"=>"Han Solo"}, {"id"=>577359, "name"=>"Carrie Fisher", "character_name"=>"Leia Organa"}, {"id"=>485272, "name"=>"Peter Cushing", "character_name"=>"Grand Moff Tarkin"}, {"id"=>532256, "name"=>"Alec Guinness", "character_name"=>"Obi-Wan Kenobi"}, {"id"=>491391, "name"=>"Anthony Daniels", "character_name"=>"C-3PO"}, {"id"=>153815, "name"=>"Kenny Baker", "character_name"=>"R2-D2"}, {"id"=>274194, "name"=>"Peter Mayhew", "character_name"=>"Chewbacca"}, ...]
```

All Images (posters, backgrounds, banners, thumbnails) must first be set before they can be accessed. Due to the fact that is takes an extra Guidebox query to retrieve all the images, they are not initially set to minimize the amount of required queries. To set the images for a movie object, simply do the following:
```ruby
movie.images=(<Your API key>)
```
This will allow you to retrieve the proper values from the following methods:
```ruby
movie.large_posters
# => [{"url"=>"http://static-api.guidebox.com/thumbnails_movies/35899-7025719867-6648234203-7915630294-large-400x570.jpg", "width"=>400, "height"=>570}, ...]
movie.medium_posters
# => [{"url"=>"http://static-api.guidebox.com/thumbnails_movies_medium/35899-1790661379-2837163895-8028762201-medium-240x342.jpg", "width"=>240, "height"=>342}, ...]
movie.small_posters
# => [{"url"=>"http://static-api.guidebox.com/thumbnails_movies_small/35899-6837106645-4376499262-8650679979-small-120x171.jpg", "width"=>120, "height"=>171}, ...]
movie.xlarge_banners
# => [{"url"=>"http://static-api.guidebox.com/012915/movies/banners/35899-9631411582-5908639450-2857491984-1300x240.jpg", "width"=>1300, "height"=>240}, ...]
movie.large_banners
# => [{"url"=>"http://static-api.guidebox.com/012915/movies/banners/35899-9631411582-5908639450-2857491984-1000x185.jpg", "width"=>1000, "height"=>185}, ...]
movie.medium_banners
# => [{"url"=>"http://static-api.guidebox.com/012915/movies/banners/35899-9631411582-5908639450-2857491984-756x140.jpg", "width"=>756, "height"=>140}, ...]
movie.small_banners
# => [{"url"=>"http://static-api.guidebox.com/012915/movies/banners/35899-9631411582-5908639450-2857491984-551x102.jpg", "width"=>551, "height"=>102}, ...]
movie.xlarge_thumbnails
# => [{"url"=>"http://static-api.guidebox.com/012915/movies/thumbnails/35899-3488454409-126609994-9253611676-608x342.jpg", "width"=>608, "height"=>342}, ...]
movie.large_thumbnails
# => [{"url"=>"http://static-api.guidebox.com/012915/movies/thumbnails/35899-3488454409-126609994-9253611676-448x252.jpg", "width"=>448, "height"=>252}, ...]
movie.medium_thumbnails
# => [{"url"=>"http://static-api.guidebox.com/012915/movies/thumbnails/35899-3488454409-126609994-9253611676-304x171.jpg", "width"=>304, "height"=>171}, ...]
movie.small_thumbnails
# => [{"url"=>"http://static-api.guidebox.com/012915/movies/thumbnails/35899-3488454409-126609994-9253611676-208x117.jpg", "width"=>208, "height"=>117}, ...]
```

#### Tv Helpers

```ruby
Expand All @@ -122,80 +144,69 @@ guidebox_tv.search_for_by_provider("entourage", "hbo")
guidebox_tv.search_by_db_id("tt0387199", "imdb")
# => {"id"=>6085, "title"=>"Entourage", "alternate_titles"=>[], "container_show"=>0, "first_aired"=>"2004-07-18", "imdb_id"=>"tt0387199", ...}

guidebox_tv.fetch_tv_show_by_db_id("tt0387199", "imdb")
# => <Movie>

guidebox_tv.show_information("entourage")
# => {"id"=>6085, "title"=>"Entourage", "alternate_titles"=>[], "status"=>"Ended", "type"=>"television", "container_show"=>0, "first_aired"=>"2004-07-18", "network"=>"HBO", "channels"=>[{"id"=>36, "name"=>"HBO", "short_name"=>"hbo", ...}

guidebox_tv.seasons("entourage")
# => [{"season_number"=>1, "first_airdate"=>"2004-07-18"}, {"season_number"=>2, "first_airdate"=>"2005-06-05"}, {"season_number"=>3, "first_airdate"=>"2006-06-11"}, {"season_number"=>4, "first_airdate"=>"2007-06-17"}, ...]

guidebox_tv.cast("entourage")
# => [{"id"=>40080, "name"=>"Kevin Connolly", "character_name"=>"Eric Murphy"}, {"id"=>349611, "name"=>"Adrian Grenier", "character_name"=>"Vincent Chase"}, {"id"=>275528, "name"=>"Jerry Ferrara", "character_name"=>"Turtle"}, {"id"=>71709, "name"=>"Kevin Dillon", "character_name"=>"Johnny \"Drama\" Chase"}, {"id"=>491504, "name"=>"Jeremy Piven", "character_name"=>"Ari Gold"}, ...]

guidebox_tv.status("entourage")
# => "Ended"

guidebox_tv.type("entourage")
# => "television"

guidebox_tv.first_aired("entourage")
# => "2004-07-18"

guidebox_tv.network("entourage")
# => "HBO"

guidebox_tv.channel_information("entourage")
# => [{"id"=>36, "name"=>"HBO", "short_name"=>"hbo", "channel_type"=>"television", "artwork_208x117"=>"http://static-api.guidebox.com/041014/thumbnails_small/36-4192732312-208x117-channel.jpg", ...}]

guidebox_tv.runtime("entourage")
# => 30
guidebox_tv.fetch_tv_show("entourage")
# => <Movie>
```

guidebox_tv.genres("entourage")
# => [{"id"=>6, "title"=>"Comedy"}, {"id"=>9, "title"=>"Drama"}]
#### Accessbile Tv Attributes

guidebox_tv.tags("entourage")
# => [{"id"=>919, "tag"=>"beverly hills"}, {"id"=>1624, "tag"=>"beverly hills california"}, {"id"=>44, "tag"=>"male friendship"}, {"id"=>293, "tag"=>"aspiring actor"}, {"id"=>295, "tag"=>"hollywood"}, ...]
```ruby
:id, :title, :alternative_titles, :status, :first_aired, :network,
:channels, :runtime, :genres, :tags, :cast, :overview, :air_day_of_week,
:air_time, :rating, :imdb_id, :tvdb, :themoviedb, :freebase, :tv_com,
:metacritic, :wikipedia_id, :tvrage, :fanart, :poster, :banner, :url,
:artwork, :social, :seasons, :season_total, :related,
:posters, :banners, :thumbnails, :backgrounds
```

guidebox_tv.overview("entourage")
# => "Vincent Chase is a young actor whose career is on the rise. Joining him on his journey to stardom are his childhood buddies Eric, Turtle, his brother Johnny Drama and his hot-tempered agent Ari Gold. Together, they'll navigate the highs and lows of Hollywood's fast lane, where the stakes are higher -- and the money and temptations greater -- than ever before. "
These can easily be accessed as follows:
```ruby
guidebox_tv = GuideboxWrapper::GuideboxTv.new("YOUR_API_KEY", "region")
show = guidebox_tv.fetch_movie("entourage")

guidebox_tv.air_day_of_week("entourage")
# => "Sunday"
show.title
# => "Entourage"

guidebox_tv.air_time("entourage")
# => "10:30 PM"
show.status
# => "Ended"

guidebox_tv.rating("entourage")
show.rating
# => "TV-MA"
```

guidebox_tv.imdb_id("entourage")
# => "tt0387199"

guidebox_tv.metacritic_link("entourage")
# => "http://www.metacritic.com/tv/entourage"

guidebox_tv.wikipedia_id("entourage")
# => 907282

guidebox_tv.facebook_link("entourage")
# => "https://www.facebook.com/Entourage"

guidebox_tv.twitter_link("entourage")
# => nil

guidebox_tv.related_show("entourage")
# => {"total_results"=>6, "total_returned"=>6, "results"=>[{"id"=>300, "title"=>"Suits", "alternate_titles"=>[], "container_show"=>0, "first_aired"=>"2011-06-23", "imdb_id"=>"tt1632701", "tvdb"=>247808, "themoviedb"=>37680, "freebase"=>"/m/0gg70vv", "wikipedia_id"=>30987670, "tvrage"=>{"tvrage_id"=>27518, "link"=>"http://www.tvrage.com/shows/id-27518"}, "artwork_208x117"=>"http://static-api.guidebox.com/091414/thumbnails_small/300-4352846579-208x117-show-thumbnail.jpg", "artwork_304x171"=>"http://static-api.guidebox.com/091414/thumbnails_medium/300-2030188479-304x171-show-thumbnail.jpg", "artwork_448x252"=>"http://static-api.guidebox.com/091414/thumbnails_large/300-9888987527-448x252-show-thumbnail.jpg", "artwork_608x342"=>"http://static-api.guidebox.com/091414/thumbnails_xlarge/300-9276088145-608x342-show-thumbnail.jpg"}, ...]}

guidebox_tv.posters("entourage")
# => [{"xlarge"=>{"url"=>"http://static-api.guidebox.com/012915/shows/posters/6085-3725524591-5295090941-3912000982-600x855.jpg", "width"=>600, "height"=>855}, "large"=>{"url"=>"http://static-api.guidebox.com/012915/shows/posters/6085-3725524591-5295090941-3912000982-400x570.jpg", "width"=>400, "height"=>570}, ...}]

guidebox_tv.thumbnail_images("entourage")
# => [{"xlarge"=>{"url"=>"http://static-api.guidebox.com/091414/thumbnails_xlarge/6085-6340779560-608x342-show-thumbnail.jpg", "width"=>608, "height"=>342}, "large"=>{"url"=>"http://static-api.guidebox.com/091414/thumbnails_large/6085-6218685578-448x252-show-thumbnail.jpg", "width"=>448, "height"=>252}, ...}]

guidebox_tv.banner_images("entourage")
# => [{"xlarge"=>{"url"=>"http://static-api.guidebox.com/012915/shows/banners/6085-6918728002-5154230813-6413012026-1300x240.jpg", "width"=>1300, "height"=>240}, "large"=>{"url"=>"http://static-api.guidebox.com/012915/shows/banners/6085-6918728002-5154230813-6413012026-1000x185.jpg", "width"=>1000, "height"=>185}, ...]
All Images (posters, backgrounds, banners, thumbnails), Season Information, Accessible Sources, and Related Shows must first be set before they can be accessed. Due to the fact that is takes an extra Guidebox query to retrieve all the images, they are not initially set to minimize the amount of required queries. To set the images for a movie object, simply do the following:
```ruby
show.images=(<Your API key>)
show.seasons=(<Your API key>)
show.sources=(<Your API key>)
show.related=(<Your API key>)
```

guidebox_tv.background_images("entourage")
# => [{"original"=>{"url"=>"http://static-api.guidebox.com/012915/shows/backgrounds/6085-96932638085-133215735918-888.jpg", "width"=>1280, "height"=>720}, "original_width"=>1280, "original_height"=>720, "image_rating"=>0}, ...]
This will allow you to retrieve the proper values from the following methods:
```ruby
show.seasons
show.season_total
show.related
show.posters
show.banners
show.thumbnails
show.backgrounds
show.web_sources
show.ios_sources
show.android_sources
show.free_sources
show.subscription_sources
show.purchase_sources
show.small_artwork
show.medium_artwork
show.large_artwork
show.xlarge_artwork
```

## Development
Expand Down
18 changes: 18 additions & 0 deletions lib/GuideboxWrapper/guidebox_movie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,24 @@ def search_by_db_id(id, type)
@client.query(url)
end

def fetch_movie_by_db_id(id, type)
url = @base_url + "/search/movie/id/"
case type
when "themoviedb"
url += "themoviedb/" + id.to_s
when "imdb"
url += "imdb/" + id.to_s
else
puts "That id type does not exist"
return
end
id = @client.query(url)["id"]
url = @base_url
url += "/movie/" + id.to_s
results = @client.query(url)
Movie.new(results)
end

def show_information(name)
id = self.search_for(name).first["id"]
url = @base_url
Expand Down
17 changes: 17 additions & 0 deletions spec/movie_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,23 @@
end
end
end
describe "#fetch_movie_by_db_id" do
before(:all) do
@guidebox_wrapper = GuideboxWrapper::GuideboxMovie.new(ENV["MY_API_KEY"], "all")
end
context "themoviedb" do
it "returns movie with attributes for star wars" do
star_wars = @guidebox_wrapper.fetch_movie_by_db_id(11, "themoviedb")
expect(star_wars).to have_attributes(:id => 55413, :title => "Star Wars: Episode IV: A New Hope", :rating => "PG")
end
end
context "imdb" do
it "returns movie with attributes for star wars" do
star_wars = @guidebox_wrapper.fetch_movie_by_db_id("tt0076759", "imdb")
expect(star_wars).to have_attributes(:id => 55413, :title => "Star Wars: Episode IV: A New Hope", :rating => "PG")
end
end
end
describe "#show_information" do
it "returns information for Star Wars: A New Hope" do
results = guidebox.show_information("star wars a new hope")
Expand Down

0 comments on commit e4a3175

Please sign in to comment.