lib/movie.rb in pirate-autonzb-0.4.5 vs lib/movie.rb in pirate-autonzb-0.5.0
- old
+ new
@@ -1,7 +1,6 @@
require File.join(File.dirname(__FILE__), 'imdb')
-require File.join(File.dirname(__FILE__), 'nfo')
class Movie
include Comparable
attr_accessor :path, :name, :format, :source, :sound, :encoding, :year, :srt, :lang, :score, :tags, :age,
@@ -10,21 +9,27 @@
def initialize(raw_name, attributes = {})
@raw_name = raw_name.gsub(/\.|\_/,' ')
attributes.each { |k,v| self.send("#{k}=", v) }
@srt, @tags = [], []
+ # for info set with nzbs title
+ if name && year && score
+ @info_get_from_title = true
+ end
+
set_name
set_year
set_format
set_source
set_sound
set_srt
set_lang
set_encoding
set_tags
+
set_imdb_id
- set_data_from_imdb unless path
+ set_data_from_imdb unless path || @info_get_from_title
end
def score
@score ||= imdb.score
end
@@ -63,11 +68,11 @@
nil
end
end
def set_name
- if @name.nil?
+ if name.nil?
raw_name = @raw_name.gsub(/\(|\)|\[|\]|\{|\}|\//, ' ')
if matched = raw_name.match(/(.*)(19[0-9]{2}|20[0-9]{2})[^p]/)
@name = matched[1]
elsif matched = raw_name.match(/(.*)1080p/i)
@name = matched[1]
@@ -80,11 +85,13 @@
@name.gsub!(/^\s+|\s+$/u,'')
end
end
def set_year
- if matched = @raw_name.match(/19[0-9]{2}|20[0-9]{2}/)
- @year = matched[0].to_i
+ if year.nil?
+ if matched = @raw_name.match(/19[0-9]{2}|20[0-9]{2}/)
+ @year = matched[0].to_i
+ end
end
end
def set_format
@format = case @raw_name
\ No newline at end of file