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
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/movlog/omdb_api.rb', line 29 def self.location(movie_id) page_url = "http://www.imdb.com/title/#{movie_id}/locations?ref_=tt_dt_dt" # Fetch and parse HTML document 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} location_arr.to_json end |
.movie_info(t) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# 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', r: 'json' } ) JSON.load(movie_response.to_s) end |