GuideboxWrapper 0.1.6 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6ac4616ee5d13ab0f3f0bb1a6f532ff8a701888b
4
- data.tar.gz: ce4c0e29f8537538bc20641ee182cdb4aa893d1a
3
+ metadata.gz: f0f2b0e0bbc96f0eb5d045b8869328c76206d053
4
+ data.tar.gz: 1f6a1b6073f6c857873f2fbd0fbbc32b847f4246
5
5
  SHA512:
6
- metadata.gz: c8d7f69fdefbbdea51066b7a06f808a451e65adc4cc9748f71bfc0379cfaa391e5a4ad4b9dad5cf2b8e4806a5457130d732f25bc358f19e08aa16a0f3eac99da
7
- data.tar.gz: 5923af732cf7ba6089228deb01176c7a72af7df80b81199dcdc9135af68c49ffd0cc1dc03b2f8fa3becbf2b072e6d96c5c853e63b80429caf3d2fddb1b2445e8
6
+ metadata.gz: cf2753cf8898a6cc630195e625efe65d84e600dacbda78bfce016d21dfa1b4f28dbd6cdfc85d09ca821ceae68aff139935b67e85a59e8dfba11f0b4144578ddc
7
+ data.tar.gz: 093f911a9019aa3cda69e5f30d7d664fe3a88f4037002af381f19394ee0b900728d9637f63b3d239b65f120138df5b685ff9c8e4a6b0864d5d028aaa7117f259
Binary file
data/README.md CHANGED
@@ -68,20 +68,12 @@ guidebox_movie.search_by_db_id(11, "themoviedb")
68
68
  guidebox_movie.show_information("star wars a new hope")
69
69
  # => {"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.", ...}
70
70
 
71
- guidebox_movie.posters("star wars a new hope")
72
- # => [{"large"=>{"url"=>"http://static-api.guidebox.com/022615/thumbnails_movies/-alt--55413-2929921416-5712237544-4512474872-large-400x570-alt-.jpg", "width"=>400, "height"=>570}, ...]
73
-
74
- guidebox_movie.thumbnail_images("star wars a new hope")
75
- # => [{"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}, ...]
76
-
77
- guidebox_movie.banner_images("star wars a new hope")
78
- # => [{"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}, ...]
79
-
80
- guidebox_movie.background_images("star wars a new hope")
81
- # => [{"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}]
82
-
83
71
  guidebox_movie.fetch_movie("star wars a new hope")
84
72
  # => <Movie>
73
+
74
+ guidebox_movie.fetch_movie_by_db_id("tt0076759", "imdb")
75
+ # => <Movie>
76
+ # The first parameter is the external database id (if imdb the id should be a string, if themoviedb it should be an integer)
85
77
  ```
86
78
 
87
79
  #### Accessbile Movie Attributes
@@ -91,7 +83,7 @@ guidebox_movie.fetch_movie("star wars a new hope")
91
83
  :rottentomatoes, :alternate_titles, :freebase, :wikipedia_id, :metacritic_link, :overview, :genres, :tags, :facebook_link,
92
84
  :web_trailers, :ios_trailers, :android_trailers, :free_web_sources, :free_ios_sources, :free_android_sources, :tv_everywhere_web_sources,
93
85
  :tv_everywhere_ios_sources, :tv_everywhere_android_sources, :subscription_web_sources, :purchase_web_sources, :purchase_ios_sources,
94
- :purchase_android_sources
86
+ :purchase_android_sources, :posters, :backgrounds, :banners, :thumbnails
95
87
  ```
96
88
  These can be easily accessed as follows:
97
89
  ```ruby
@@ -108,6 +100,36 @@ movie.cast
108
100
  # => [{"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"}, ...]
109
101
  ```
110
102
 
103
+ 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:
104
+ ```ruby
105
+ movie.images=(<Your API key>)
106
+ ```
107
+ This will allow you to retrieve the proper values from the following methods:
108
+ ```ruby
109
+ movie.large_posters
110
+ # => [{"url"=>"http://static-api.guidebox.com/thumbnails_movies/35899-7025719867-6648234203-7915630294-large-400x570.jpg", "width"=>400, "height"=>570}, ...]
111
+ movie.medium_posters
112
+ # => [{"url"=>"http://static-api.guidebox.com/thumbnails_movies_medium/35899-1790661379-2837163895-8028762201-medium-240x342.jpg", "width"=>240, "height"=>342}, ...]
113
+ movie.small_posters
114
+ # => [{"url"=>"http://static-api.guidebox.com/thumbnails_movies_small/35899-6837106645-4376499262-8650679979-small-120x171.jpg", "width"=>120, "height"=>171}, ...]
115
+ movie.xlarge_banners
116
+ # => [{"url"=>"http://static-api.guidebox.com/012915/movies/banners/35899-9631411582-5908639450-2857491984-1300x240.jpg", "width"=>1300, "height"=>240}, ...]
117
+ movie.large_banners
118
+ # => [{"url"=>"http://static-api.guidebox.com/012915/movies/banners/35899-9631411582-5908639450-2857491984-1000x185.jpg", "width"=>1000, "height"=>185}, ...]
119
+ movie.medium_banners
120
+ # => [{"url"=>"http://static-api.guidebox.com/012915/movies/banners/35899-9631411582-5908639450-2857491984-756x140.jpg", "width"=>756, "height"=>140}, ...]
121
+ movie.small_banners
122
+ # => [{"url"=>"http://static-api.guidebox.com/012915/movies/banners/35899-9631411582-5908639450-2857491984-551x102.jpg", "width"=>551, "height"=>102}, ...]
123
+ movie.xlarge_thumbnails
124
+ # => [{"url"=>"http://static-api.guidebox.com/012915/movies/thumbnails/35899-3488454409-126609994-9253611676-608x342.jpg", "width"=>608, "height"=>342}, ...]
125
+ movie.large_thumbnails
126
+ # => [{"url"=>"http://static-api.guidebox.com/012915/movies/thumbnails/35899-3488454409-126609994-9253611676-448x252.jpg", "width"=>448, "height"=>252}, ...]
127
+ movie.medium_thumbnails
128
+ # => [{"url"=>"http://static-api.guidebox.com/012915/movies/thumbnails/35899-3488454409-126609994-9253611676-304x171.jpg", "width"=>304, "height"=>171}, ...]
129
+ movie.small_thumbnails
130
+ # => [{"url"=>"http://static-api.guidebox.com/012915/movies/thumbnails/35899-3488454409-126609994-9253611676-208x117.jpg", "width"=>208, "height"=>117}, ...]
131
+ ```
132
+
111
133
  #### Tv Helpers
112
134
 
113
135
  ```ruby
@@ -122,80 +144,69 @@ guidebox_tv.search_for_by_provider("entourage", "hbo")
122
144
  guidebox_tv.search_by_db_id("tt0387199", "imdb")
123
145
  # => {"id"=>6085, "title"=>"Entourage", "alternate_titles"=>[], "container_show"=>0, "first_aired"=>"2004-07-18", "imdb_id"=>"tt0387199", ...}
124
146
 
147
+ guidebox_tv.fetch_tv_show_by_db_id("tt0387199", "imdb")
148
+ # => <Movie>
149
+
125
150
  guidebox_tv.show_information("entourage")
126
151
  # => {"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", ...}
127
152
 
128
- guidebox_tv.seasons("entourage")
129
- # => [{"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"}, ...]
130
-
131
- guidebox_tv.cast("entourage")
132
- # => [{"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"}, ...]
133
-
134
- guidebox_tv.status("entourage")
135
- # => "Ended"
136
-
137
- guidebox_tv.type("entourage")
138
- # => "television"
139
-
140
- guidebox_tv.first_aired("entourage")
141
- # => "2004-07-18"
142
-
143
- guidebox_tv.network("entourage")
144
- # => "HBO"
145
-
146
- guidebox_tv.channel_information("entourage")
147
- # => [{"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", ...}]
148
-
149
- guidebox_tv.runtime("entourage")
150
- # => 30
153
+ guidebox_tv.fetch_tv_show("entourage")
154
+ # => <Movie>
155
+ ```
151
156
 
152
- guidebox_tv.genres("entourage")
153
- # => [{"id"=>6, "title"=>"Comedy"}, {"id"=>9, "title"=>"Drama"}]
157
+ #### Accessbile Tv Attributes
154
158
 
155
- guidebox_tv.tags("entourage")
156
- # => [{"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"}, ...]
159
+ ```ruby
160
+ :id, :title, :alternative_titles, :status, :first_aired, :network,
161
+ :channels, :runtime, :genres, :tags, :cast, :overview, :air_day_of_week,
162
+ :air_time, :rating, :imdb_id, :tvdb, :themoviedb, :freebase, :tv_com,
163
+ :metacritic, :wikipedia_id, :tvrage, :fanart, :poster, :banner, :url,
164
+ :artwork, :social, :seasons, :season_total, :related,
165
+ :posters, :banners, :thumbnails, :backgrounds
166
+ ```
157
167
 
158
- guidebox_tv.overview("entourage")
159
- # => "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. "
168
+ These can easily be accessed as follows:
169
+ ```ruby
170
+ guidebox_tv = GuideboxWrapper::GuideboxTv.new("YOUR_API_KEY", "region")
171
+ show = guidebox_tv.fetch_movie("entourage")
160
172
 
161
- guidebox_tv.air_day_of_week("entourage")
162
- # => "Sunday"
173
+ show.title
174
+ # => "Entourage"
163
175
 
164
- guidebox_tv.air_time("entourage")
165
- # => "10:30 PM"
176
+ show.status
177
+ # => "Ended"
166
178
 
167
- guidebox_tv.rating("entourage")
179
+ show.rating
168
180
  # => "TV-MA"
181
+ ```
169
182
 
170
- guidebox_tv.imdb_id("entourage")
171
- # => "tt0387199"
172
-
173
- guidebox_tv.metacritic_link("entourage")
174
- # => "http://www.metacritic.com/tv/entourage"
175
-
176
- guidebox_tv.wikipedia_id("entourage")
177
- # => 907282
178
-
179
- guidebox_tv.facebook_link("entourage")
180
- # => "https://www.facebook.com/Entourage"
181
-
182
- guidebox_tv.twitter_link("entourage")
183
- # => nil
184
-
185
- guidebox_tv.related_show("entourage")
186
- # => {"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"}, ...]}
187
-
188
- guidebox_tv.posters("entourage")
189
- # => [{"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}, ...}]
190
-
191
- guidebox_tv.thumbnail_images("entourage")
192
- # => [{"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}, ...}]
193
-
194
- guidebox_tv.banner_images("entourage")
195
- # => [{"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}, ...]
183
+ 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:
184
+ ```ruby
185
+ show.images=(<Your API key>)
186
+ show.seasons=(<Your API key>)
187
+ show.sources=(<Your API key>)
188
+ show.related=(<Your API key>)
189
+ ```
196
190
 
197
- guidebox_tv.background_images("entourage")
198
- # => [{"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}, ...]
191
+ This will allow you to retrieve the proper values from the following methods:
192
+ ```ruby
193
+ show.seasons
194
+ show.season_total
195
+ show.related
196
+ show.posters
197
+ show.banners
198
+ show.thumbnails
199
+ show.backgrounds
200
+ show.web_sources
201
+ show.ios_sources
202
+ show.android_sources
203
+ show.free_sources
204
+ show.subscription_sources
205
+ show.purchase_sources
206
+ show.small_artwork
207
+ show.medium_artwork
208
+ show.large_artwork
209
+ show.xlarge_artwork
199
210
  ```
200
211
 
201
212
  ## Development
@@ -38,6 +38,24 @@ module GuideboxWrapper
38
38
  @client.query(url)
39
39
  end
40
40
 
41
+ def fetch_movie_by_db_id(id, type)
42
+ url = @base_url + "/search/movie/id/"
43
+ case type
44
+ when "themoviedb"
45
+ url += "themoviedb/" + id.to_s
46
+ when "imdb"
47
+ url += "imdb/" + id.to_s
48
+ else
49
+ puts "That id type does not exist"
50
+ return
51
+ end
52
+ id = @client.query(url)["id"]
53
+ url = @base_url
54
+ url += "/movie/" + id.to_s
55
+ results = @client.query(url)
56
+ Movie.new(results)
57
+ end
58
+
41
59
  def show_information(name)
42
60
  id = self.search_for(name).first["id"]
43
61
  url = @base_url
@@ -50,42 +68,7 @@ module GuideboxWrapper
50
68
  id = set_name_or_id(name_or_id)
51
69
  url += "/movie/" + id.to_s
52
70
  results = @client.query(url)
53
- url += "/images/all"
54
- images_results = @client.query(url)
55
- images = images_results["results"]
56
- Movie.new(results, images)
57
- end
58
-
59
- def posters(name_or_id)
60
- url = @base_url
61
- id = set_name_or_id(name_or_id)
62
- url += "/movie/" + id.to_s + "/images/posters"
63
- results = @client.query(url)
64
- results["results"]["posters"]
65
- end
66
-
67
- def thumbnail_images(name_or_id)
68
- url = @base_url
69
- id = set_name_or_id(name_or_id)
70
- url += "/movie/" + id.to_s + "/images/thumbnails"
71
- results = @client.query(url)
72
- results["results"]["thumbnails"]
73
- end
74
-
75
- def banner_images(name_or_id)
76
- url = @base_url
77
- id = set_name_or_id(name_or_id)
78
- url += "/movie/" + id.to_s + "/images/banners"
79
- results = @client.query(url)
80
- results["results"]["banners"]
81
- end
82
-
83
- def background_images(name_or_id)
84
- url = @base_url
85
- id = set_name_or_id(name_or_id)
86
- url += "/movie/" + id.to_s + "/images/backgrounds"
87
- results = @client.query(url)
88
- results["results"]["backgrounds"]
71
+ Movie.new(results)
89
72
  end
90
73
  end
91
74
  end
@@ -1,4 +1,5 @@
1
1
  require 'GuideboxWrapper/query_builders/tv/tv_query_builders'
2
+ require 'GuideboxWrapper/tv/tv'
2
3
 
3
4
  module GuideboxWrapper
4
5
  class GuideboxTv < GuideboxApi
@@ -41,191 +42,40 @@ module GuideboxWrapper
41
42
  @client.query(url)
42
43
  end
43
44
 
44
- # Get all tv show info
45
- def show_information(name)
46
- id = self.search_for(name).first["id"]
45
+ def fetch_tv_show_by_db_id(id, type)
46
+ url = @base_url + "/search/id/"
47
+ case type
48
+ when "tvdb"
49
+ url += "tvdb/" + id.to_s
50
+ when "themoviedb"
51
+ url += "themoviedb/" + id.to_s
52
+ when "imdb"
53
+ url += "imdb/" + id
54
+ else
55
+ puts "That id type does not exist"
56
+ return
57
+ end
58
+ id = @client.query(url)["id"]
47
59
  url = @base_url
48
60
  url += "/show/" + id.to_s
49
- @client.query(url)
50
- end
51
-
52
- # Get all seasons of show by name
53
- def seasons(name)
54
- id = self.search_for(name).first["id"]
55
- url = @base_url
56
- url += "/show/" + id.to_s + "/seasons"
57
- data = @client.query(url)
58
- data["results"]
59
- end
60
-
61
- # Get the cast of show by show name
62
- def cast(name)
63
- url = search_and_set_url(name)
64
- results = @client.query(url)
65
- results["cast"]
66
- end
67
-
68
- # Get the status of show by name ex. Ended
69
- def status(name)
70
- url = search_and_set_url(name)
71
- results = @client.query(url)
72
- results["status"]
73
- end
74
-
75
- # Get type of show by name ex. TV
76
- def type(name)
77
- url = search_and_set_url(name)
78
- results = @client.query(url)
79
- results["type"]
80
- end
81
-
82
- # Get show first aired date by name
83
- def first_aired(name)
84
- url = search_and_set_url(name)
85
- results = @client.query(url)
86
- results["first_aired"]
87
- end
88
-
89
- # Get network aired on, ex HBO
90
- def network(name)
91
- url = search_and_set_url(name)
92
- results = @client.query(url)
93
- results["network"]
94
- end
95
-
96
- # Get channel information of show by name
97
- def channel_information(name)
98
- url = search_and_set_url(name)
99
- results = @client.query(url)
100
- results["channels"]
101
- end
102
-
103
- # Get runtime of show by name
104
- def runtime(name)
105
- url = search_and_set_url(name)
106
- results = @client.query(url)
107
- results["runtime"]
108
- end
109
-
110
- # Get genres of show by show name ex. Drama, Comedy
111
- def genres(name)
112
- url = search_and_set_url(name)
113
- results = @client.query(url)
114
- results["genres"]
115
- end
116
-
117
- # Get tags of show by name
118
- def tags(name)
119
- url = search_and_set_url(name)
120
- results = @client.query(url)
121
- results["tags"]
122
- end
123
-
124
- # Get overview or description of show by name
125
- def overview(name)
126
- url = search_and_set_url(name)
127
- results = @client.query(url)
128
- results["overview"]
129
- end
130
-
131
- # Get air day of the week by show name
132
- def air_day_of_week(name)
133
- url = search_and_set_url(name)
134
- results = @client.query(url)
135
- results["air_day_of_week"]
136
- end
137
-
138
- # Get air time of the day by show name
139
- def air_time(name)
140
- url = search_and_set_url(name)
141
- results = @client.query(url)
142
- results["air_time"]
143
- end
144
-
145
- # Get show rating by name ex. TV-MA
146
- def rating(name)
147
- url = search_and_set_url(name)
148
- results = @client.query(url)
149
- results["rating"]
150
- end
151
-
152
- # Get imdb id by show name
153
- def imdb_id(name)
154
- url = search_and_set_url(name)
155
- results = @client.query(url)
156
- results["imdb_id"]
157
- end
158
-
159
- # Get metacritic link by show name
160
- def metacritic_link(name)
161
- url = search_and_set_url(name)
162
- results = @client.query(url)
163
- results["metacritic"]
164
- end
165
-
166
- # Get wikipedia id by show name
167
- def wikipedia_id(name)
168
- url = search_and_set_url(name)
169
- results = @client.query(url)
170
- results["wikipedia_id"]
171
- end
172
-
173
- # Get facebook_link by show name
174
- def facebook_link(name)
175
- url = search_and_set_url(name)
176
61
  results = @client.query(url)
177
- results["social"]["facebook"]["link"]
62
+ Tv.new(results)
178
63
  end
179
64
 
180
- # Get twitter_link by name
181
- def twitter_link(name)
182
- url = search_and_set_url(name)
183
- results = @client.query(url)
184
- results["social"]["twitter"]["link"]
185
- end
186
-
187
- # Gets all related tv shows by show id
188
- def related_shows(name)
65
+ # Get all tv show info
66
+ def show_information(name)
189
67
  id = self.search_for(name).first["id"]
190
68
  url = @base_url
191
- url += "/show/" + id.to_s + "/related"
69
+ url += "/show/" + id.to_s
192
70
  @client.query(url)
193
71
  end
194
72
 
195
- # Gets all tv show movie posters
196
- def posters(name_or_id)
197
- url = @base_url
198
- id = set_name_or_id(name_or_id)
199
- url += "/show/" + id.to_s + "/images/posters"
200
- results = @client.query(url)
201
- results["results"]["posters"]
202
- end
203
-
204
- # Gets all show thumbnail images by name or id
205
- def thumbnail_images(name_or_id)
73
+ def fetch_tv_show(name_or_id)
206
74
  url = @base_url
207
75
  id = set_name_or_id(name_or_id)
208
- url += "/show/" + id.to_s + "/images/thumbnails"
209
- results = @client.query(url)
210
- results["results"]["thumbnails"]
211
- end
212
-
213
- # Gets all show banner images by name or id
214
- def banner_images(name_or_id)
215
- url = @base_url
216
- id = set_name_or_id(name_or_id)
217
- url += "/show/" + id.to_s + "/images/banners"
218
- results = @client.query(url)
219
- results["results"]["banners"]
220
- end
221
-
222
- # Gets all show background images by name or id
223
- def background_images(name_or_id)
224
- url = @base_url
225
- id = set_name_or_id(name_or_id)
226
- url += "/show/" + id.to_s + "/images/backgrounds"
76
+ url += "/show/" + id.to_s
227
77
  results = @client.query(url)
228
- results["results"]["backgrounds"]
78
+ Tv.new(results)
229
79
  end
230
80
  end
231
81
  end
@@ -8,6 +8,7 @@ module GuideboxWrapper
8
8
  end
9
9
  end
10
10
  class GuideboxApi
11
+ attr_reader :region, :base_url, :client
11
12
  def initialize(key, region)
12
13
  @key = key
13
14
  @region = region
@@ -1,8 +1,9 @@
1
1
  module GuideboxWrapper
2
2
  class Movie
3
3
  attr_reader :id, :title, :release_year, :cast, :writers, :directors, :release_date, :rating, :duration, :themoviedb, :imdb, :rottentomatoes, :alternate_titles, :freebase, :wikipedia_id, :metacritic, :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, :posters, :backgrounds, :banners, :thumbnails
4
+ attr_accessor :posters, :backgrounds, :banners, :thumbnails
4
5
 
5
- def initialize(movie_info, images)
6
+ def initialize(movie_info)
6
7
  excluded_keys = ["common_sense_media", "poster_120x171", "poster_240x342", "poster_400x570", "social", "trailers"]
7
8
  movie_info.each do |key, value|
8
9
  unless excluded_keys.include?(key)
@@ -13,10 +14,19 @@ module GuideboxWrapper
13
14
  @web_trailers = movie_info["trailers"]["web"]
14
15
  @ios_trailers = movie_info["trailers"]["ios"]
15
16
  @android_trailers = movie_info["trailers"]["android"]
16
- @posters = images["posters"]
17
- @backgrounds = images["backgrounds"]
18
- @banners = images["banners"]
19
- @thumbnails = images["thumbnails"]
17
+ end
18
+
19
+ def images=(api_key)
20
+ if @posters == nil
21
+ wrapper = GuideboxWrapper::GuideboxMovie.new(api_key, "all")
22
+ url = wrapper.base_url
23
+ url += "/movie/" + @id.to_s + "/images/all"
24
+ images = wrapper.client.query(url)["results"]
25
+ @posters = images["posters"]
26
+ @backgrounds = images["backgrounds"]
27
+ @banners = images["banners"]
28
+ @thumbnails = images["thumbnails"]
29
+ end
20
30
  end
21
31
 
22
32
  def large_posters
@@ -0,0 +1,129 @@
1
+ module GuideboxWrapper
2
+ class Tv
3
+ attr_reader :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
4
+ attr_accessor :seasons, :season_total, :related, :posters, :banners, :thumbnails, :backgrounds
5
+
6
+ def initialize(show_info)
7
+ excluded_keys = ["common_sense_media", "type", "artwork_208x117", "artwork_304x171", "artwork_448x252", "artwork_608x342"]
8
+ show_info.each do |key, value|
9
+ unless excluded_keys.include?(key)
10
+ instance_variable_set("@#{key}", value)
11
+ end
12
+ end
13
+ @facebook_link = show_info["social"]["facebook"]["link"]
14
+ @artwork = { "artwork_208x117" => show_info["artwork_208x117"], "artwork_304x171" => show_info["artwork_304x171"], "artwork_448x252" => show_info["artwork_448x252"], "artwork_608x342" => show_info["artwork_608x342"] }
15
+ end
16
+
17
+ def images=(api_key)
18
+ if @posters == nil
19
+ wrapper = set_base_url(api_key)
20
+ url = wrapper.base_url + "/show/" + @id.to_s + "/images/all"
21
+ images = wrapper.client.query(url)["results"]
22
+ @posters = images["posters"]
23
+ @backgrounds = images["backgrounds"]
24
+ @banners = images["banners"]
25
+ @thumbnails = images["thumbnails"]
26
+ end
27
+ end
28
+
29
+ def seasons=(api_key)
30
+ if @seasons == nil
31
+ wrapper = set_base_url(api_key)
32
+ url = wrapper.base_url + "/show/" + @id.to_s + "/seasons"
33
+ results = wrapper.client.query(url)
34
+ @seasons = results["results"]
35
+ @season_total = results["total_results"]
36
+ end
37
+ end
38
+
39
+ def sources=(api_key)
40
+ unless @sources != nil
41
+ @sources = get_data(api_key, "sources")
42
+ end
43
+ end
44
+
45
+ def related=(api_key)
46
+ unless @related != nil
47
+ @related = get_data(api_key, "related")
48
+ end
49
+ end
50
+
51
+ def web_sources
52
+ @sources == nil ? "You need to call sources=(api_key) first" : @sources["web"]
53
+ end
54
+
55
+ def ios_sources
56
+ @sources == nil ? "You need to call sources=(api_key) first" : @sources["ios"]
57
+ end
58
+
59
+ def android_sources
60
+ @sources == nil ? "You need to call sources=(api_key) first" : @sources["android"]
61
+ end
62
+
63
+ def free_sources
64
+ if @sources != nil
65
+ add_sources("free")
66
+ else
67
+ "You need to call sources=(api_key) first"
68
+ end
69
+ end
70
+
71
+ def subscription_sources
72
+ if @sources != nil
73
+ add_sources("subscription")
74
+ else
75
+ "You need to call sources=(api_key) first"
76
+ end
77
+ end
78
+
79
+ def purchase_sources
80
+ if @sources != nil
81
+ add_sources("purchase")
82
+ else
83
+ "You need to call sources=(api_key) first"
84
+ end
85
+ end
86
+
87
+ def small_artwork
88
+ @artwork["artwork_208x117"]
89
+ end
90
+
91
+ def medium_artwork
92
+ @artwork["artwork_304x171"]
93
+ end
94
+
95
+ def large_artwork
96
+ @artwork["artwork_448x252"]
97
+ end
98
+
99
+ def xlarge_artwork
100
+ @artwork["artwork_608x342"]
101
+ end
102
+
103
+ private
104
+
105
+ def add_sources(type)
106
+ x = []
107
+ web_sources["episodes"]["all_sources"].each { |source| x << (source.merge({ "type" => "web" })) if source["type"] == type }
108
+ ios_sources["episodes"]["all_sources"].each { |source| x << (source.merge({ "type" => "ios" })) if source["type"] == type }
109
+ android_sources["episodes"]["all_sources"].each { |source| x << (source.merge({ "type" => "android" })) if source["type"] == type }
110
+ x
111
+ end
112
+
113
+ def set_base_url(api_key)
114
+ wrapper = GuideboxWrapper::GuideboxTv.new(api_key, "all")
115
+ wrapper
116
+ end
117
+
118
+ def get_data(api_key, type)
119
+ wrapper = set_base_url(api_key)
120
+ case type
121
+ when "sources"
122
+ url = wrapper.base_url + "/show/" + @id.to_s + "/available_content"
123
+ when "related"
124
+ url = wrapper.base_url + "/show/" + @id.to_s + "/related"
125
+ end
126
+ wrapper.client.query(url)["results"]
127
+ end
128
+ end
129
+ end
@@ -1,3 +1,3 @@
1
1
  module GuideboxWrapper
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.9"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: GuideboxWrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Baird
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-01-25 00:00:00.000000000 Z
11
+ date: 2016-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -81,6 +81,7 @@ files:
81
81
  - CODE_OF_CONDUCT.md
82
82
  - Gemfile
83
83
  - GuideboxWrapper-0.1.5.gem
84
+ - GuideboxWrapper-0.1.6.gem
84
85
  - GuideboxWrapper.gemspec
85
86
  - LICENSE.txt
86
87
  - README.md
@@ -94,6 +95,7 @@ files:
94
95
  - lib/GuideboxWrapper/movie/movie.rb
95
96
  - lib/GuideboxWrapper/query_builders/movie/movie_query_builders.rb
96
97
  - lib/GuideboxWrapper/query_builders/tv/tv_query_builders.rb
98
+ - lib/GuideboxWrapper/tv/tv.rb
97
99
  - lib/GuideboxWrapper/version.rb
98
100
  homepage: https://github.com/tmobaird/GuideboxWrapper
99
101
  licenses: