lib/imdb.rb in pirate-autonzb-0.4.3 vs lib/imdb.rb in pirate-autonzb-0.4.4
- old
+ new
@@ -6,10 +6,11 @@
class IMDB
attr_accessor :link, :doc, :id
def initialize(name, year = nil, link = nil)
+ @try = 3
@name, @year, @link = name, year, link
@coder = HTMLEntities.new
set_doc
set_id
end
@@ -57,9 +58,17 @@
@id = movie_url.match(/tt[0-9]+/)[0]
end
else # direct in movie page
@doc = doc
end
+ end
+ rescue
+ if @try > 0
+ @try -= 1
+ $stdout.print '*'
+ set_doc
+ else
+ @doc = nil
end
end
def set_id
@id ||= doc.search("a[@href*='/title/tt']").first[:href].match(/tt[0-9]+/)[0] if doc
\ No newline at end of file