Class: Movlog::OmdbApi
- Inherits:
-
Object
- Object
- Movlog::OmdbApi
- Defined in:
- lib/movlog/omdb_api.rb
Overview
Service for all OMDB API calls
Constant Summary collapse
- OMDB_URL =
'http://www.omdbapi.com/'
Class Method Summary collapse
Class Method Details
.location(movie_id) ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/movlog/omdb_api.rb', line 42 def self.location(movie_id) page_url = "http://www.imdb.com/title/#{movie_id}/locations?ref_=tt_dt_dt" location_arr = [] doc = Nokogiri::HTML(open(page_url)) doc.search('//div[@class="soda sodavote odd"]/dt/a').each { |link| location_arr << link.content} doc.search('//div[@class="soda sodavote even"]/dt/a').each { |link| location_arr << link.content} JSON.parse(location_arr.to_json) end |
.movie_info(t) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/movlog/omdb_api.rb', line 16 def self.movie_info(t) movie_response = HTTP.get( OMDB_URL, params: { t: t, y: '', plot: 'short', type: 'movie', r: 'json' } ) JSON.parse(movie_response.to_s) end |
.search_movie(s) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/movlog/omdb_api.rb', line 30 def self.search_movie(s) movie_response = HTTP.get( OMDB_URL, params: { s: s, type: 'movie', r: 'json' } ) JSON.parse(movie_response.to_s) end |