spotlite 0.7.1 → 0.7.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.
- data/CHANGELOG.md +6 -0
- data/lib/spotlite/movie.rb +10 -9
- data/lib/spotlite/person.rb +2 -2
- data/lib/spotlite/string_extensions.rb +5 -0
- data/lib/spotlite/top.rb +5 -4
- data/lib/spotlite/version.rb +1 -1
- data/spec/fixtures/movies_coming_soon +802 -1928
- data/spec/fixtures/movies_in_theaters +966 -1194
- data/spec/fixtures/nm0005132/index +2707 -4432
- data/spec/fixtures/nm0864666/index +1233 -1239
- data/spec/fixtures/nm1659547/index +2339 -3797
- data/spec/fixtures/search_no_results +287 -134
- data/spec/fixtures/search_the_core +293 -139
- data/spec/fixtures/top +10756 -1025
- data/spec/fixtures/tt0002186/index +538 -590
- data/spec/fixtures/tt0047396/releaseinfo +395 -301
- data/spec/fixtures/tt0112873/index +727 -591
- data/spec/fixtures/tt0133093/criticreviews +358 -266
- data/spec/fixtures/tt0133093/fullcredits +7368 -752
- data/spec/fixtures/tt0133093/index +750 -883
- data/spec/fixtures/tt0133093/keywords +595 -495
- data/spec/fixtures/tt0133093/mediaindex_still_frame +305 -168
- data/spec/fixtures/tt0133093/releaseinfo +373 -279
- data/spec/fixtures/tt0133093/trivia +1754 -1184
- data/spec/fixtures/tt0169547/index +767 -901
- data/spec/fixtures/tt0317248/index +810 -966
- data/spec/fixtures/tt1134629/fullcredits +4516 -750
- data/spec/spotlite/movie_spec.rb +1 -1
- data/spec/spotlite/top_spec.rb +1 -0
- metadata +17 -9
- checksums.yaml +0 -7
data/CHANGELOG.md
CHANGED
data/lib/spotlite/movie.rb
CHANGED
@@ -133,29 +133,29 @@ module Spotlite
|
|
133
133
|
# Returns a list of directors as an array of hashes
|
134
134
|
# with keys: +imdb_id+ (string) and +name+ (string)
|
135
135
|
def directors
|
136
|
-
parse_staff(
|
136
|
+
parse_staff("Directed by")
|
137
137
|
end
|
138
138
|
|
139
139
|
# Returns a list of writers as an array of hashes
|
140
140
|
# with keys: +imdb_id+ (string) and +name+ (string)
|
141
141
|
def writers
|
142
|
-
parse_staff(
|
142
|
+
parse_staff("Writing Credits")
|
143
143
|
end
|
144
144
|
|
145
145
|
# Returns a list of producers as an array of hashes
|
146
146
|
# with keys: +imdb_id+ (string) and +name+ (string)
|
147
147
|
def producers
|
148
|
-
parse_staff(
|
148
|
+
parse_staff("Produced by")
|
149
149
|
end
|
150
150
|
|
151
151
|
# Returns a list of actors as an array of hashes
|
152
152
|
# with keys: +imdb_id+ (string), +name+ (string), and +character+ (string)
|
153
153
|
def cast
|
154
|
-
table = full_credits.css("table.
|
155
|
-
names = table.css("td
|
156
|
-
links = table.css("td
|
154
|
+
table = full_credits.css("table.cast_list")
|
155
|
+
names = table.css("td[itemprop='actor']").map { |node| node.text.strip } rescue []
|
156
|
+
links = table.css("td[itemprop='actor'] a").map { |node| node["href"].clean_href } rescue []
|
157
157
|
imdb_ids = links.map { |link| link.parse_imdb_id } unless links.empty?
|
158
|
-
characters = table.css("td.
|
158
|
+
characters = table.css("td.character").map { |node| node.text.clean_character }
|
159
159
|
|
160
160
|
array = []
|
161
161
|
0.upto(names.size - 1) do |i|
|
@@ -271,8 +271,9 @@ module Spotlite
|
|
271
271
|
|
272
272
|
def parse_staff(staff) # :nodoc:
|
273
273
|
array = []
|
274
|
-
table = full_credits.at("a[name='#{staff}']").parent.parent.parent.parent rescue nil
|
275
|
-
|
274
|
+
# table = full_credits.at("a[name='#{staff}']").parent.parent.parent.parent rescue nil
|
275
|
+
table = full_credits.search("[text()*='#{staff}']").first.next_element rescue nil
|
276
|
+
if table && table.name == "table"
|
276
277
|
table.css("a[href^='/name/nm']").map do |node|
|
277
278
|
imdb_id = node["href"].parse_imdb_id
|
278
279
|
name = node.text.strip
|
data/lib/spotlite/person.rb
CHANGED
@@ -19,12 +19,12 @@ module Spotlite
|
|
19
19
|
|
20
20
|
# Returns name as a string
|
21
21
|
def name
|
22
|
-
@name ||= details.at("h1.header[itemprop='name']").text.strip.clean_name
|
22
|
+
@name ||= details.at("h1.header span[itemprop='name']").text.strip.clean_name
|
23
23
|
end
|
24
24
|
|
25
25
|
# Returns name at birth as a string
|
26
26
|
def birth_name
|
27
|
-
details.at("#
|
27
|
+
details.at("#name-born-info a[href^='/name/']").text.strip rescue nil
|
28
28
|
end
|
29
29
|
|
30
30
|
# Returns birth date as a date
|
@@ -37,6 +37,11 @@ class String
|
|
37
37
|
gsub(/\n.+$/, "")
|
38
38
|
end
|
39
39
|
|
40
|
+
# Strip all extra white space from character's name node
|
41
|
+
def clean_character
|
42
|
+
strip.gsub(/ \n /, "")
|
43
|
+
end
|
44
|
+
|
40
45
|
# Strips parantheses from release date's comment
|
41
46
|
def clean_release_comment
|
42
47
|
gsub("\n", "").gsub(") (", ", ").gsub("(", "").gsub(")", "")
|
data/lib/spotlite/top.rb
CHANGED
@@ -4,11 +4,12 @@ module Spotlite
|
|
4
4
|
|
5
5
|
# Returns an array of +Spotlite::Movie+ objects
|
6
6
|
def parse_movies
|
7
|
-
page.css("table
|
8
|
-
imdb_id =
|
9
|
-
title =
|
7
|
+
page.css("table.chart td.titleColumn").map do |cell|
|
8
|
+
imdb_id = cell.at("a[href^='/title/tt']")['href'].parse_imdb_id
|
9
|
+
title = cell.at("a[href^='/title/tt']").text.strip
|
10
|
+
year = cell.at("span.secondaryInfo").text.parse_year
|
10
11
|
|
11
|
-
[imdb_id, title]
|
12
|
+
[imdb_id, title, year]
|
12
13
|
end.map do |values|
|
13
14
|
Spotlite::Movie.new(*values)
|
14
15
|
end
|
data/lib/spotlite/version.rb
CHANGED