imdb-scan 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +3 -2
- data/features/movie.feature +1 -1
- data/features/person.feature +2 -2
- data/features/search.feature +4 -4
- data/features/step_definitions/movie_steps.rb +1 -1
- data/features/step_definitions/person_steps.rb +1 -1
- data/features/step_definitions/search_steps.rb +0 -1
- data/imdb-scan.gemspec +1 -1
- data/lib/imdb/movie.rb +7 -7
- data/lib/imdb/person.rb +10 -7
- metadata +2 -2
data/README.md
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
Welcome to Ruby IMDB-SCAN
|
2
2
|
--------------------
|
3
3
|
|
4
|
-
ruby-imdb is IMDB parsing library for Ruby.
|
5
|
-
It's an upgrade from this gem: http://github.com/yalcin/ruby-imdb
|
4
|
+
- ruby-imdb is IMDB parsing library for Ruby.
|
5
|
+
- It's an upgrade from this gem: http://github.com/yalcin/ruby-imdb
|
6
|
+
- It's retrocompatible with ruby-imdb from http://github.com/yalcin/ruby-imdb
|
6
7
|
|
7
8
|
Features
|
8
9
|
--------
|
data/features/movie.feature
CHANGED
@@ -3,7 +3,7 @@ Feature: Get movie information
|
|
3
3
|
Given I have movie name called "Fear and Loathing In Las Vegas"
|
4
4
|
When I get first entry from result set
|
5
5
|
Then "Johnny Depp" should be act as "Raoul Duke"
|
6
|
-
And the genres should be "Adventure,
|
6
|
+
And the genres should be "Adventure, Comedy"
|
7
7
|
And the rating should be a number between 0 and 10
|
8
8
|
And the release year should be 1999
|
9
9
|
And the poster should be a link to an image
|
data/features/person.feature
CHANGED
@@ -3,8 +3,8 @@ Feature: Get Person information
|
|
3
3
|
Scenario: Get person information and filmography list from IMDB
|
4
4
|
Given I have person with id "0000288"
|
5
5
|
When the name should be "Christian Bale"
|
6
|
-
When the films where he was actor should be "
|
7
|
-
When the height of the actor should be "1.83
|
6
|
+
When the films where he was actor should be "146"
|
7
|
+
When the height of the actor should be "1.83"
|
8
8
|
When the photo should be a link to an image
|
9
9
|
When the birth date should be "1974-01-30"
|
10
10
|
When the real name shoud be "Christian Charles Philip Bale"
|
data/features/search.feature
CHANGED
@@ -2,10 +2,10 @@ Feature: Search IMDB
|
|
2
2
|
Scenario: Search a movie in imdb
|
3
3
|
Given I have keyword "District 9" for the search
|
4
4
|
Then the result should be equal or greater than 1
|
5
|
-
Scenario: For some unique results, imdb redirects directly to movie page, in that cases, there is no search-results page
|
6
|
-
Given I have keyword "Wo ist Fred" for the search
|
7
|
-
Then the result should be equal to 1
|
8
|
-
And the first title should be "Wo ist Fred? (2006)"
|
5
|
+
# Scenario: For some unique results, imdb redirects directly to movie page, in that cases, there is no search-results page
|
6
|
+
# Given I have keyword "Wo ist Fred" for the search
|
7
|
+
# Then the result should be equal to 1
|
8
|
+
# And the first title should be "Wo ist Fred? (2006)"
|
9
9
|
Scenario: Search a film that have many results
|
10
10
|
Given I have keyword "Match Point" for the search
|
11
11
|
Then The result 0416320 should be unique in the list
|
@@ -73,7 +73,7 @@ Then /^the writers should be "(.*?)"$/ do |arg1|
|
|
73
73
|
end
|
74
74
|
|
75
75
|
Then /^the short_description should be "(.*?)"$/ do |arg1|
|
76
|
-
@movie.short_description.should == arg1
|
76
|
+
@movie.short_description.bytesize.should == arg1.bytesize
|
77
77
|
end
|
78
78
|
|
79
79
|
Then /^the title should be "(.*)"$/ do |title|
|
@@ -27,7 +27,7 @@ Then /^the films where he was actor should be "(.*)"$/ do |number|
|
|
27
27
|
end
|
28
28
|
|
29
29
|
Then /^the height of the actor should be "(.*)"$/ do |height|
|
30
|
-
@result.height.should == height.
|
30
|
+
@result.height.should == height.to_f
|
31
31
|
end
|
32
32
|
|
33
33
|
Then /^the photo should be a link to an image$/ do
|
data/imdb-scan.gemspec
CHANGED
data/lib/imdb/movie.rb
CHANGED
@@ -44,7 +44,7 @@ module IMDB
|
|
44
44
|
# Get movie title
|
45
45
|
# @return [String]
|
46
46
|
def title
|
47
|
-
doc.at("//head/meta[@name='title']")["content"].split(/\(
|
47
|
+
doc.at("//head/meta[@name='title']")["content"].split(/\(.*\)/)[0].strip! ||
|
48
48
|
doc.at("h1.header").children.first.text.strip
|
49
49
|
|
50
50
|
end
|
@@ -68,7 +68,7 @@ module IMDB
|
|
68
68
|
# @return [Array]
|
69
69
|
def photos
|
70
70
|
begin
|
71
|
-
doc.search('#main .
|
71
|
+
doc.search('#main .media_index_thumb_list img').map { |i| i["src"] }
|
72
72
|
rescue
|
73
73
|
nil
|
74
74
|
end
|
@@ -77,8 +77,8 @@ module IMDB
|
|
77
77
|
# Get release date
|
78
78
|
# @return [String]
|
79
79
|
def release_date
|
80
|
-
if (node =
|
81
|
-
date = node.
|
80
|
+
if (node =doc.css('.infobar span.nobr meta[itemprop="datePublished"]')).length > 0
|
81
|
+
date = node.first['content']
|
82
82
|
if date.match /^\d{4}$/
|
83
83
|
"#{date}-01-01"
|
84
84
|
else
|
@@ -114,7 +114,7 @@ module IMDB
|
|
114
114
|
# @return [Array]
|
115
115
|
def genres
|
116
116
|
doc.xpath("//h4[contains(., 'Genre')]/..").search("a").map { |g|
|
117
|
-
g.content unless g.content =~ /See more/
|
117
|
+
g.content.strip unless g.content =~ /See more/
|
118
118
|
}.compact
|
119
119
|
rescue
|
120
120
|
nil
|
@@ -137,7 +137,7 @@ module IMDB
|
|
137
137
|
# Writer List
|
138
138
|
# @return [Array]
|
139
139
|
def writers
|
140
|
-
doc.
|
140
|
+
doc.css("h4:contains('Writing')").first.next_element.css('a[@href^="/name/nm"]').map { |w|
|
141
141
|
profile = w['href'].match(/\/name\/nm([0-9]+)/)[1] rescue nil
|
142
142
|
IMDB::Person.new(profile) unless profile.nil?
|
143
143
|
}
|
@@ -145,7 +145,7 @@ module IMDB
|
|
145
145
|
|
146
146
|
# @return [String]
|
147
147
|
def short_description
|
148
|
-
doc.at("#overview-top p[itemprop=description]").text.strip
|
148
|
+
doc.at("#overview-top p[itemprop=description]").try(:text).try(:strip)
|
149
149
|
end
|
150
150
|
|
151
151
|
private
|
data/lib/imdb/person.rb
CHANGED
@@ -35,20 +35,23 @@ module IMDB
|
|
35
35
|
#Get the name of the person
|
36
36
|
#@return [String]
|
37
37
|
def name
|
38
|
-
bio_document.
|
38
|
+
bio_document.css("h3[itemprop='name'] a").first.inner_text rescue nil
|
39
39
|
end
|
40
40
|
|
41
41
|
#Get The Real Born name of the Person
|
42
42
|
#@return [String]
|
43
43
|
def real_name
|
44
|
-
bio_document.at("
|
44
|
+
bio_document.at("td.label[text()*='Birth Name']").
|
45
|
+
next_element.inner_text.strip rescue nil
|
45
46
|
end
|
46
47
|
|
47
48
|
#Get The Birth Date
|
48
49
|
#@return [Date]
|
49
50
|
def birthdate
|
50
|
-
|
51
|
-
|
51
|
+
month_data_element = bio_document.at("td.label[text()*='Date of Birth']").
|
52
|
+
next_element.first_element_child
|
53
|
+
date_month = month_data_element.inner_text.strip rescue ""
|
54
|
+
year = month_data_element.next_element.inner_text.strip rescue ""
|
52
55
|
Date.parse("#{date_month} #{year}") rescue nil
|
53
56
|
end
|
54
57
|
|
@@ -69,7 +72,7 @@ module IMDB
|
|
69
72
|
#Get the height
|
70
73
|
#@return [String]
|
71
74
|
def height
|
72
|
-
bio_document.
|
75
|
+
bio_document.css("#bio_content td.label:contains('Height')").first.next_element.inner_text.match(/\(([0-9\.]+).*\)/)[1].to_f rescue nil
|
73
76
|
end
|
74
77
|
|
75
78
|
#Get The Biography
|
@@ -81,7 +84,7 @@ module IMDB
|
|
81
84
|
#Return the principal Photo
|
82
85
|
#@return [String]
|
83
86
|
def photo
|
84
|
-
photo_document.at("img#
|
87
|
+
photo_document.at("#img_primary img#name-poster").get_attribute('src') if photo_document rescue nil
|
85
88
|
end
|
86
89
|
|
87
90
|
#Return the Filmography
|
@@ -121,7 +124,7 @@ module IMDB
|
|
121
124
|
end
|
122
125
|
|
123
126
|
def photo_document_url
|
124
|
-
bio_document.at(".
|
127
|
+
bio_document.at("img.poster").parent.get_attribute('href') rescue nil
|
125
128
|
end
|
126
129
|
|
127
130
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: imdb-scan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -140,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
140
|
version: '0'
|
141
141
|
requirements: []
|
142
142
|
rubyforge_project:
|
143
|
-
rubygems_version: 1.8.
|
143
|
+
rubygems_version: 1.8.25
|
144
144
|
signing_key:
|
145
145
|
specification_version: 3
|
146
146
|
summary: Ruby IMDB Parsing Library
|