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.
Files changed (2) hide show
  1. data/lib/yay_imdbs.rb +14 -7
  2. 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("//div[@class = 'photo']/a/img")
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['small_image'] = thumbnail_url
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("//div[@class = 'photo']/a").first['href']
126
- large_img_doc = Nokogiri::HTML(open('http://www.imdb.com' + large_img_page))
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
- return Nokogiri::HTML(open(IMDB_SEARCH_URL + URI.escape(name)))
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
- return Nokogiri::HTML(open(IMDB_MOVIE_URL + imdb_id))
162
+ Nokogiri::HTML(open(IMDB_MOVIE_URL + imdb_id))
160
163
  end
161
164
 
162
165
  def self.get_episodes_page(imdb_id)
163
- return Nokogiri::HTML(open(IMDB_MOVIE_URL + imdb_id + '/episodes'))
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
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 6
9
- version: 0.1.6
8
+ - 7
9
+ version: 0.1.7
10
10
  platform: ruby
11
11
  authors:
12
12
  - Sam Cavenagh