yayimdbs 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/yay_imdbs.rb +18 -11
- metadata +7 -7
data/lib/yay_imdbs.rb
CHANGED
@@ -61,7 +61,7 @@ class YayImdbs
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def self.scrap_movie_info(imdb_id)
|
64
|
-
info_hash = {}.with_indifferent_access
|
64
|
+
info_hash = {:imdb_id => imdb_id}.with_indifferent_access
|
65
65
|
|
66
66
|
doc = self.get_movie_page(imdb_id)
|
67
67
|
info_hash['title'], info_hash['year'] = get_title_and_year_from_meta(doc)
|
@@ -113,12 +113,23 @@ class YayImdbs
|
|
113
113
|
raise "No info divs found for imdb id #{imdb_id}"
|
114
114
|
end
|
115
115
|
|
116
|
+
self.scrap_images(doc, info_hash)
|
116
117
|
|
118
|
+
#scrap episodes if tv series
|
119
|
+
if info_hash.has_key?('season')
|
120
|
+
self.scrap_episodes(doc, info_hash)
|
121
|
+
end
|
122
|
+
|
123
|
+
return info_hash
|
124
|
+
end
|
125
|
+
|
126
|
+
private
|
127
|
+
def self.scrap_images(doc, info_hash)
|
117
128
|
#scrap poster image urls
|
118
129
|
thumb = doc.xpath("//td[@id = 'img_primary']/a/img")
|
119
130
|
if thumb.first
|
120
131
|
thumbnail_url = thumb.first['src']
|
121
|
-
if not thumbnail_url =~
|
132
|
+
if not thumbnail_url =~ /\/nopicture\//
|
122
133
|
info_hash['medium_image'] = thumbnail_url
|
123
134
|
|
124
135
|
# Small thumbnail image, gotten by hacking medium url
|
@@ -131,11 +142,11 @@ class YayImdbs
|
|
131
142
|
info_hash['large_image'] = large_img_url
|
132
143
|
end
|
133
144
|
end
|
134
|
-
|
135
|
-
|
136
|
-
|
145
|
+
end
|
146
|
+
|
147
|
+
def self.scrap_episodes(doc, info_hash)
|
137
148
|
episodes = []
|
138
|
-
doc = self.get_episodes_page(imdb_id)
|
149
|
+
doc = self.get_episodes_page(info_hash[:imdb_id])
|
139
150
|
episode_divs = doc.css(".filter-all")
|
140
151
|
episode_divs.each do |e_div|
|
141
152
|
if e_div.xpath('.//h3').inner_text =~ /Season (\d+), Episode (\d+):/
|
@@ -148,12 +159,8 @@ class YayImdbs
|
|
148
159
|
end
|
149
160
|
end
|
150
161
|
info_hash['episodes'] = episodes
|
151
|
-
|
152
|
-
|
153
|
-
return info_hash
|
154
|
-
end
|
162
|
+
end
|
155
163
|
|
156
|
-
private
|
157
164
|
def self.get_search_page(name)
|
158
165
|
Nokogiri::HTML(open(IMDB_SEARCH_URL + URI.escape(name)))
|
159
166
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 8
|
9
|
+
version: 0.1.8
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Sam Cavenagh
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-10-
|
17
|
+
date: 2010-10-14 00:00:00 +11:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -86,10 +86,10 @@ dependencies:
|
|
86
86
|
- - ">="
|
87
87
|
- !ruby/object:Gem::Version
|
88
88
|
segments:
|
89
|
-
-
|
90
|
-
-
|
91
|
-
-
|
92
|
-
version:
|
89
|
+
- 2
|
90
|
+
- 0
|
91
|
+
- 0
|
92
|
+
version: 2.0.0
|
93
93
|
type: :development
|
94
94
|
version_requirements: *id005
|
95
95
|
description: A simple imdb scraper built on Nokogiri for ruby 1.9+
|