class Movlog::OmdbApi

Service for all OMDB API calls

Constants

OMDB_URL

Public Class Methods

location(movie_id) click to toggle source
# File lib/movlog/omdb_api.rb, line 42
def self.location(movie_id)
  location_arr = []
  doc = Nokogiri::HTML(open(location_url(movie_id)))
  doc.search('//div[@class="soda sodavote odd"]/dt/a').each { |link| location_arr << link.content.gsub(/\n/, '') }
  doc.search('//div[@class="soda sodavote even"]/dt/a').each { |link| location_arr <<  link.content.gsub(/\n/, '') }
  JSON.parse(location_arr.to_json)
end
movie_info(t) click to toggle source
# 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) click to toggle source
# 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

Private Class Methods

location_url(imdb_id) click to toggle source
# File lib/movlog/omdb_api.rb, line 52
def self.location_url(imdb_id)
   "http://www.imdb.com/title/#{imdb_id}/locations?ref_=tt_dt_dt"
end