movlog 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 235092a14091018697156dd0247ef139acb6cc83
4
- data.tar.gz: c2d463159be3fc95aa01166f4248c3080d4741f1
3
+ metadata.gz: ca827d42329ec03e5c7305f8a6bf8c7c4adc55ec
4
+ data.tar.gz: a1737f13302af870e35b596288600eb89e747a57
5
5
  SHA512:
6
- metadata.gz: 27fd8f7caefc641f957378454d1bf4a2c54ab992bb8cb699ce18c57b977b63f26f2761e53579ebca27ca0db1288c91486d4292ba03835bb2837847cfaaa79693
7
- data.tar.gz: e019295273bf62b8fe32d4cd345f959911d9421e02a575e250ad7764e61e61895005e330eaecbfcba94ab0f2364e4769ed2a3498404a33522663eacd5333b86a
6
+ metadata.gz: ab39aeea635567717b294d5c200cefa844fa392da0562420e96718725c66960bc330fd8228959a918133e42e300b01ddeab30b82e775fc709c4d2ee3f6ba0cdb
7
+ data.tar.gz: f27cd7fe6fab144da3ab45c31a656139ed95f637f9e79065381d04e915f5dda7f53173aee0bc5c894aee976e3d3113ca946f4e99cdf967a357feb2d8667c85d7
data/lib/movlog/movie.rb CHANGED
@@ -4,21 +4,23 @@ require_relative 'omdb_api'
4
4
  module Movlog
5
5
  # Movie info
6
6
  class Movie
7
- attr_reader :imdb_id, :title, :year, :actors, :poster, :plot, :response
7
+ attr_reader :imdb_id, :title, :year, :actors, :poster, :plot, :location
8
8
 
9
- def initialize(data:)
9
+ def initialize(data:,location:)
10
10
  @imdb_id = data['imdbID']
11
11
  @title = data['Title']
12
12
  @year = data['Year']
13
13
  @actors = data['Actors']
14
14
  @poster = data['Poster']
15
15
  @plot = data['Plot']
16
- @response = data['Response']
16
+ @location = location
17
17
  end
18
18
 
19
19
  def self.find(t:)
20
20
  movie_data = OmdbApi.movie_info(t)
21
- new(data: movie_data)
21
+ imdb_id = movie_data['imdbID']
22
+ location = OmdbApi.location(imdb_id)
23
+ new(data: movie_data,location: location)
22
24
  end
23
25
  end
24
26
  end
@@ -1,3 +1,9 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'nokogiri'
5
+ require 'open-uri'
6
+
1
7
  # frozen_string_literal: true
2
8
  require 'http'
3
9
  require 'json'
@@ -19,5 +25,22 @@ module Movlog
19
25
  )
20
26
  JSON.load(movie_response.to_s)
21
27
  end
28
+
29
+ def self.location(l)
30
+ movie_id = l
31
+
32
+ page_url = "http://www.imdb.com/title/#{movie_id}/locations?ref_=tt_dt_dt"
33
+
34
+ # Fetch and parse HTML document
35
+ location_arr = []
36
+
37
+ doc = Nokogiri::HTML(open(page_url))
38
+
39
+ doc.search('//div[@class="soda sodavote odd"]/dt/a').each { |link| location_arr << link.content}
40
+
41
+ doc.search('//div[@class="soda sodavote even"]/dt/a').each { |link| location_arr << link.content}
42
+
43
+ location_arr
44
+ end
22
45
  end
23
46
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Movlog
4
- VERSION = '0.2.1'
5
- end
4
+ VERSION = '0.2.2'
5
+ end