yayimdbs 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/yay_imdbs.rb +14 -7
- metadata +2 -2
data/lib/yay_imdbs.rb
CHANGED
@@ -115,15 +115,18 @@ class YayImdbs
|
|
115
115
|
|
116
116
|
|
117
117
|
#scrap poster image urls
|
118
|
-
thumb = doc.xpath("//
|
118
|
+
thumb = doc.xpath("//td[@id = 'img_primary']/a/img")
|
119
119
|
if thumb.first
|
120
120
|
thumbnail_url = thumb.first['src']
|
121
121
|
if not thumbnail_url =~ /addposter.jpg$/
|
122
|
-
info_hash['
|
122
|
+
info_hash['medium_image'] = thumbnail_url
|
123
|
+
|
124
|
+
# Small thumbnail image, gotten by hacking medium url
|
125
|
+
info_hash['small_image'] = thumbnail_url.sub(/@@.*$/, '@@._V1._SX120_120,160_.jpg')
|
123
126
|
|
124
127
|
#Try to scrap a larger version of the image url
|
125
|
-
large_img_page = doc.xpath("//
|
126
|
-
large_img_doc =
|
128
|
+
large_img_page = doc.xpath("//td[@id = 'img_primary']/a").first['href']
|
129
|
+
large_img_doc = self.get_media_page(large_img_page)
|
127
130
|
large_img_url = large_img_doc.xpath("//img[@id = 'primary-img']").first['src'] unless large_img_doc.xpath("//img[@id = 'primary-img']").empty?
|
128
131
|
info_hash['large_image'] = large_img_url
|
129
132
|
end
|
@@ -152,17 +155,21 @@ class YayImdbs
|
|
152
155
|
|
153
156
|
private
|
154
157
|
def self.get_search_page(name)
|
155
|
-
|
158
|
+
Nokogiri::HTML(open(IMDB_SEARCH_URL + URI.escape(name)))
|
156
159
|
end
|
157
160
|
|
158
161
|
def self.get_movie_page(imdb_id)
|
159
|
-
|
162
|
+
Nokogiri::HTML(open(IMDB_MOVIE_URL + imdb_id))
|
160
163
|
end
|
161
164
|
|
162
165
|
def self.get_episodes_page(imdb_id)
|
163
|
-
|
166
|
+
Nokogiri::HTML(open(IMDB_MOVIE_URL + imdb_id + '/episodes'))
|
164
167
|
end
|
165
168
|
|
169
|
+
def self.get_media_page(url_fragment)
|
170
|
+
Nokogiri::HTML(open(IMDB_BASE_URL + url_fragment))
|
171
|
+
end
|
172
|
+
|
166
173
|
def self.get_title_and_year_from_meta(doc)
|
167
174
|
return nil, nil unless doc.xpath("//meta[@name='title']").first
|
168
175
|
|