Sha256: 43da2dc1ba8e70508ff850950a1c99ba5297841965f0c1663fee76423fe4168d
Contents?: true
Size: 984 Bytes
Versions: 1
Compression:
Stored size: 984 Bytes
Contents
#! /usr/bin/env ruby require 'rubygems' require 'nokogiri' require 'open-uri' # frozen_string_literal: true require 'http' require 'json' module Movlog # Service for all OMDB API calls class OmdbApi OMDB_URL = 'http://www.omdbapi.com/' 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 def self.location(l) movie_id = l 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} JSON.parse(location_arr.to_s) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
movlog-0.2.5 | lib/movlog/omdb_api.rb |