royw-imdb 0.0.13 → 0.0.14
Sign up to get free protection for your applications and to get access to all the features.
- data/README +3 -2
- data/lib/imdb/imdb_movie.rb +22 -13
- metadata +2 -2
data/README
CHANGED
@@ -27,6 +27,7 @@ ImdbMovie Indiana Jones and the Last Crusade
|
|
27
27
|
- should get the aspect ratio
|
28
28
|
- should convert to xml
|
29
29
|
- should convert to yaml
|
30
|
+
- should be able to convert to and then from xml
|
30
31
|
|
31
32
|
ImdbMovie Han robado una estrella
|
32
33
|
- should query IMDB url
|
@@ -89,6 +90,6 @@ String unescape_html
|
|
89
90
|
String strip_tags
|
90
91
|
- should strip HTML tags
|
91
92
|
|
92
|
-
Finished in
|
93
|
+
Finished in 4.131553 seconds
|
93
94
|
|
94
|
-
|
95
|
+
65 examples, 0 failures
|
data/lib/imdb/imdb_movie.rb
CHANGED
@@ -165,10 +165,17 @@ class ImdbMovie
|
|
165
165
|
# return a hash with country abbreviations for keys and the certification string for the value
|
166
166
|
# example: {'USA' => 'Approved'}
|
167
167
|
def certifications
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
168
|
+
certs = []
|
169
|
+
cert_set = document.search("h5[text()='Certification:'] ~ a[@href*=/List?certificates']").map { |link| link.innerHTML.strip } rescue []
|
170
|
+
cert_set.each do |line|
|
171
|
+
if line =~ /(.*):(.*)/
|
172
|
+
cert_hash = {}
|
173
|
+
cert_hash['country'] = $1
|
174
|
+
cert_hash['rating'] = $2
|
175
|
+
certs << cert_hash
|
176
|
+
end
|
177
|
+
end
|
178
|
+
certs
|
172
179
|
end
|
173
180
|
|
174
181
|
def to_hash
|
@@ -210,18 +217,20 @@ class ImdbMovie
|
|
210
217
|
def document
|
211
218
|
attempts = 0
|
212
219
|
begin
|
213
|
-
if
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
220
|
+
if @document.nil?
|
221
|
+
if ImdbMovie::use_html_cache
|
222
|
+
begin
|
223
|
+
filespec = self.url.gsub(/^http:\//, 'spec/samples').gsub(/\/$/, '.html')
|
224
|
+
html = open(filespec).read
|
225
|
+
rescue Exception
|
226
|
+
html = open(self.url).read
|
227
|
+
cache_html_files(html)
|
228
|
+
end
|
229
|
+
else
|
218
230
|
html = open(self.url).read
|
219
|
-
cache_html_files(html)
|
220
231
|
end
|
221
|
-
|
222
|
-
html = open(self.url).read
|
232
|
+
@document = Hpricot(html)
|
223
233
|
end
|
224
|
-
@document ||= Hpricot(html)
|
225
234
|
rescue Exception => e
|
226
235
|
attempts += 1
|
227
236
|
if attempts > MAX_ATTEMPTS
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: royw-imdb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergio Gil
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-04-01 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|