myimdb 0.3.12 → 0.3.13

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.12
1
+ 0.3.13
data/bin/myimdb CHANGED
@@ -54,7 +54,7 @@ def details(klass_name, name)
54
54
  print "====================================================\n"
55
55
  print "#{site.summary}\n"
56
56
  rescue Exception=> ex
57
- p "Unable to fetch #{klass_name} details for: #{name}"
57
+ p "Unable to fetch #{klass_name} details for: #{name} because: #{ex.message}"
58
58
  end
59
59
 
60
60
  ['Imdb', 'RottenTomatoes', 'Metacritic'].each do |site|
@@ -208,6 +208,6 @@ file_paths.each do |path|
208
208
  repair_permissions_for(path)
209
209
  end
210
210
  rescue Exception=> ex
211
- puts "Unable to fetch details for: #{name}"
211
+ puts "Unable to fetch details for: #{name} because: #{ex.message}"
212
212
  end
213
213
  end
@@ -62,6 +62,9 @@ module Myimdb
62
62
  def release_date
63
63
  end
64
64
 
65
+ def image
66
+ end
67
+
65
68
  def summary
66
69
  [:directors, :writers, :rating, :votes, :genres, :tagline, :plot, :year, :release_date].collect do |meth|
67
70
  data = send(meth)
@@ -49,12 +49,20 @@ module Myimdb
49
49
  Date.parse(document.css('.info h5:contains("Release Date:") + .info-content').inner_text)
50
50
  end
51
51
 
52
+ def image
53
+ image_url = document.css(".photo:first a").first['href']
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
58
+ end
59
+
52
60
  private
53
61
  def document
54
62
  @document ||= Nokogiri::HTML(open(@url))
55
63
  end
56
64
 
57
- handle_exceptions_for :directors, :directors_with_url, :writers, :writers_with_url, :rating, :votes, :genres, :tagline, :plot, :year
65
+ handle_exceptions_for :directors, :directors_with_url, :writers, :writers_with_url, :rating, :votes, :genres, :tagline, :plot, :year, :image
58
66
  end
59
67
  end
60
68
  end
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{myimdb}
8
- s.version = "0.3.12"
8
+ s.version = "0.3.13"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Gaurav"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: myimdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.12
4
+ version: 0.3.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gaurav