Class: Shin::Data::Previewnetworks
- Inherits:
-
Object
- Object
- Shin::Data::Previewnetworks
- Defined in:
- lib/shin/data/previewnetworks.rb
Instance Method Summary collapse
-
#before(params = {}) ⇒ Object
Fix these before running.
- #new ⇒ Object
-
#search_imdb(params = {}) ⇒ Object
Search (on imdb).
Instance Method Details
#before(params = {}) ⇒ Object
Fix these before running
13 14 15 16 17 18 19 20 |
# File 'lib/shin/data/previewnetworks.rb', line 13 def before(params={}) raise MissingArgument, "You are missing the argument 'previewnetworks_key' which is required to use this source." unless Shin.get[:previewnetworks_key] != nil # Timestamp Shin.get[:previewnetworks_country] ||= "se" "http://cinema.maxplatform.com/api/json/media-feed/" + Shin.get[:previewnetworks_country] end |
#new ⇒ Object
8 9 10 |
# File 'lib/shin/data/previewnetworks.rb', line 8 def new self end |
#search_imdb(params = {}) ⇒ Object
Search (on imdb)
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/shin/data/previewnetworks.rb', line 23 def search_imdb(params={}) url = before() raise MissingArgument, "You are missing the argument 'imdb_id' which is required to use this source." unless params[:imdb_id] != "" # Response response = Base.get(url + '/cinema/all-1/' + Shin.get[:previewnetworks_key] + '/?search_field=imdb_id&search_query=' + params[:imdb_id]) raise HTTPError, "The response didn't have a 200 HTTP Code. It had #{response.code}." unless response.code == 200 data = Oj.load(response.body) rescue nil data.to_hashugar end |