Sha256: f5bd30e1fbe28b60995e1ea31db2f805ed4272e5e99a19c3b850763dbf5dc612
Contents?: true
Size: 969 Bytes
Versions: 5
Compression:
Stored size: 969 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(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 end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
movlog-0.3.2 | lib/movlog/omdb_api.rb |
movlog-0.3.1 | lib/movlog/omdb_api.rb |
movlog-0.3.0 | lib/movlog/omdb_api.rb |
movlog-0.2.12 | lib/movlog/omdb_api.rb |
movlog-0.2.11 | lib/movlog/omdb_api.rb |