myimdb 0.4.3 → 0.4.5
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/myimdb.rb +4 -10
- data/lib/myimdb/scraper/freebase.rb +1 -0
- data/lib/myimdb/scraper/imdb.rb +12 -16
- data/lib/myimdb/scraper/metacritic.rb +8 -6
- data/lib/myimdb/scraper/rotten_tomatoes.rb +7 -3
- data/lib/myimdb/scraper/string_extensions.rb +1 -1
- data/myimdb.gemspec +3 -3
- metadata +38 -14
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.2
|
data/lib/myimdb.rb
CHANGED
@@ -6,15 +6,9 @@ require 'open-uri'
|
|
6
6
|
require 'myimdb/search'
|
7
7
|
require 'myimdb/scraper'
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
define_method :search do |movie_name|
|
14
|
-
site = self.to_s.gsub('Movie', '')
|
15
|
-
search_result = Myimdb::Search::Base.search(movie_name, :restrict_to=> "#{site.downcase}.com")[0]
|
16
|
-
eval("Myimdb::Scraper::#{site}").new(search_result[:url]) if search_result
|
17
|
-
end
|
18
|
-
end
|
9
|
+
class ImdbMovie
|
10
|
+
def self.search(movie_name)
|
11
|
+
search_result = Myimdb::Search::Base.search(movie_name, :restrict_to=> 'imdb.com')[0]
|
12
|
+
Myimdb::Scraper::Imdb.new(search_result[:url]) if search_result
|
19
13
|
end
|
20
14
|
end
|
data/lib/myimdb/scraper/imdb.rb
CHANGED
@@ -6,55 +6,51 @@ module Myimdb
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def directors
|
9
|
-
document.css('.
|
9
|
+
document.css('#overview-top .txt-block h4:contains("Director") ~ a:not(:contains(" more "))').collect{ |a| a.text }
|
10
10
|
end
|
11
11
|
|
12
12
|
def directors_with_url
|
13
|
-
document.css('.
|
13
|
+
document.css('#overview-top .txt-block h4:contains("Director") ~ a:not(:contains(" more "))').collect{ |a| {:name=> a.text, :url=> "http://www.imdb.com#{a['href']}" } }
|
14
14
|
end
|
15
15
|
|
16
16
|
def writers
|
17
|
-
document.css('.
|
17
|
+
document.css('#overview-top .txt-block h4:contains("Writer") ~ a:not(:contains(" more "))').collect{ |a| a.text }
|
18
18
|
end
|
19
19
|
|
20
20
|
def writers_with_url
|
21
|
-
document.css('.
|
21
|
+
document.css('#overview-top .txt-block h4:contains("Writer") ~ a:not(:contains(" more "))').collect{ |a| {:name=> a.text, :url=> "http://www.imdb.com#{a['href']}" } }
|
22
22
|
end
|
23
23
|
|
24
24
|
def rating
|
25
|
-
document.css(".
|
25
|
+
document.css(".star-box .rating-rating").inner_text.strip.split('/').first.to_f
|
26
26
|
end
|
27
27
|
|
28
28
|
def votes
|
29
|
-
document.css(".
|
29
|
+
document.css(".star-box a[href='ratings']").inner_text.strip.split(' ').first.sub(',', '').to_i
|
30
30
|
end
|
31
31
|
|
32
32
|
def genres
|
33
|
-
document.css('.
|
33
|
+
document.css('.see-more.inline.canwrap h4:contains("Genres:") ~ a:not(:contains(" more "))').collect{ |a| a.text }
|
34
34
|
end
|
35
35
|
|
36
36
|
def tagline
|
37
|
-
document.css('.
|
37
|
+
strip_useless_chars(document.css('.txt-block h4:contains("Taglines:")').first.parent.inner_text).gsub(/Taglines |See more/, '') rescue nil
|
38
38
|
end
|
39
39
|
|
40
40
|
def plot
|
41
|
-
document.css('.
|
41
|
+
strip_useless_chars(document.css('.article h2:contains("Storyline") ~ p').inner_text).gsub(/Written by.*/, '')
|
42
42
|
end
|
43
43
|
|
44
44
|
def year
|
45
|
-
|
45
|
+
release_date.year
|
46
46
|
end
|
47
47
|
|
48
48
|
def release_date
|
49
|
-
Date.parse(document.css('
|
49
|
+
Date.parse(document.css("a[title='See all release dates']").inner_text)
|
50
50
|
end
|
51
51
|
|
52
52
|
def image
|
53
|
-
|
54
|
-
unless image_url.nil? or image_url =~ /addposter/
|
55
|
-
image_document = Nokogiri::HTML(open("http://www.imdb.com#{image_url}"))
|
56
|
-
image_document.css('#principal img:first').first['src']
|
57
|
-
end
|
53
|
+
document.css('#img_primary img').first['src']
|
58
54
|
end
|
59
55
|
|
60
56
|
private
|
@@ -6,21 +6,23 @@ module Myimdb
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def rating
|
9
|
-
document.css("
|
9
|
+
document.css(".score_value").first.inner_text.strip.to_f/10
|
10
10
|
end
|
11
11
|
|
12
12
|
def votes
|
13
|
-
document.
|
13
|
+
document.css(".summary .count a:contains('Critics')").inner_text.strip.to_i
|
14
14
|
end
|
15
15
|
|
16
16
|
def genres
|
17
|
-
document.css("
|
18
|
-
strip_useless_chars(genre)
|
19
|
-
end
|
17
|
+
document.css(".summary_detail.product_genre span.data").inner_text.gsub(/\s/, '').split(',')
|
20
18
|
end
|
21
19
|
|
22
20
|
def plot
|
23
|
-
document.css("
|
21
|
+
document.css(".summary_detail.product_summary .inline_expand_collapse.inline_collapsed span.blurb").inner_text.strip
|
22
|
+
end
|
23
|
+
|
24
|
+
def image
|
25
|
+
document.css("img.product_image.large_image").first['src']
|
24
26
|
end
|
25
27
|
|
26
28
|
private
|
@@ -6,20 +6,24 @@ module Myimdb
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def rating
|
9
|
-
document.css("
|
9
|
+
document.css(".critic_stats span")[0].inner_text.to_f
|
10
10
|
end
|
11
11
|
|
12
12
|
def votes
|
13
|
-
document.css("
|
13
|
+
document.css(".critic_stats span")[1].text.to_i
|
14
14
|
end
|
15
15
|
|
16
16
|
def genres
|
17
|
-
document.css("
|
17
|
+
document.css("span.label:contains('Genre:') + span.content span").collect{ |a| a.text }
|
18
18
|
end
|
19
19
|
|
20
20
|
def plot
|
21
21
|
document.css("#movie_synopsis_all").inner_text.strip
|
22
22
|
end
|
23
|
+
|
24
|
+
def image
|
25
|
+
document.css(".movie_poster_area a img").first['src']
|
26
|
+
end
|
23
27
|
|
24
28
|
private
|
25
29
|
def document
|
data/myimdb.gemspec
CHANGED
@@ -5,12 +5,12 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{myimdb}
|
8
|
-
s.version = "0.4.
|
8
|
+
s.version = "0.4.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Gaurav"]
|
12
|
-
s.date = %q{2010-
|
13
|
-
s.email = %q{gaurav@
|
12
|
+
s.date = %q{2010-12-16}
|
13
|
+
s.email = %q{gaurav.qwe@gmail.com}
|
14
14
|
s.executables = ["myimdb", "myimdb-catalogue"]
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE",
|
metadata
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: myimdb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 5
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 4
|
9
|
+
- 5
|
10
|
+
version: 0.4.5
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- Gaurav
|
@@ -9,31 +15,43 @@ autorequire:
|
|
9
15
|
bindir: bin
|
10
16
|
cert_chain: []
|
11
17
|
|
12
|
-
date: 2010-
|
18
|
+
date: 2010-12-16 00:00:00 -08:00
|
13
19
|
default_executable:
|
14
20
|
dependencies:
|
15
21
|
- !ruby/object:Gem::Dependency
|
16
22
|
name: httparty
|
17
|
-
|
18
|
-
|
19
|
-
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
20
26
|
requirements:
|
21
27
|
- - ">="
|
22
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 5
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
- 4
|
33
|
+
- 5
|
23
34
|
version: 0.4.5
|
24
|
-
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
25
37
|
- !ruby/object:Gem::Dependency
|
26
38
|
name: nokogiri
|
27
|
-
|
28
|
-
|
29
|
-
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
30
42
|
requirements:
|
31
43
|
- - ">="
|
32
44
|
- !ruby/object:Gem::Version
|
45
|
+
hash: 29
|
46
|
+
segments:
|
47
|
+
- 1
|
48
|
+
- 3
|
49
|
+
- 3
|
33
50
|
version: 1.3.3
|
34
|
-
|
51
|
+
type: :runtime
|
52
|
+
version_requirements: *id002
|
35
53
|
description:
|
36
|
-
email: gaurav@
|
54
|
+
email: gaurav.qwe@gmail.com
|
37
55
|
executables:
|
38
56
|
- myimdb
|
39
57
|
- myimdb-catalogue
|
@@ -74,21 +92,27 @@ rdoc_options:
|
|
74
92
|
require_paths:
|
75
93
|
- lib
|
76
94
|
required_ruby_version: !ruby/object:Gem::Requirement
|
95
|
+
none: false
|
77
96
|
requirements:
|
78
97
|
- - ">="
|
79
98
|
- !ruby/object:Gem::Version
|
99
|
+
hash: 3
|
100
|
+
segments:
|
101
|
+
- 0
|
80
102
|
version: "0"
|
81
|
-
version:
|
82
103
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
none: false
|
83
105
|
requirements:
|
84
106
|
- - ">="
|
85
107
|
- !ruby/object:Gem::Version
|
108
|
+
hash: 3
|
109
|
+
segments:
|
110
|
+
- 0
|
86
111
|
version: "0"
|
87
|
-
version:
|
88
112
|
requirements: []
|
89
113
|
|
90
114
|
rubyforge_project: myimdb
|
91
|
-
rubygems_version: 1.3.
|
115
|
+
rubygems_version: 1.3.7
|
92
116
|
signing_key:
|
93
117
|
specification_version: 3
|
94
118
|
summary: Utility gem for fetching movie details.
|