spotlite 0.7.1 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## v0.7.2 15-Dec-2013
2
+
3
+ * Fixes for updated Top 250 page
4
+ * Fixes for updated person page
5
+ * Fixes for updated movie credits page
6
+
1
7
  ## v0.7.1 12-Aug-2013
2
8
 
3
9
  * Updated `images` method following IMDb mediaindex page layout changes
@@ -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(:directors)
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(:writers)
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(:producers)
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.cast")
155
- names = table.css("td.nm").map { |node| node.text } rescue []
156
- links = table.css("td.nm a").map { |node| node["href"] } rescue []
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.char").map { |node| node.text }
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
- if table
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
@@ -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("#overview-top .txt-block a[href='bio']").text.strip rescue nil
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 a[href^='/title/tt']").map do |node|
8
- imdb_id = node['href'].parse_imdb_id
9
- title = node.text.strip
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
@@ -1,3 +1,3 @@
1
1
  module Spotlite
2
- VERSION = "0.7.1"
2
+ VERSION = "0.7.2"
3
3
  end