lib/kagu/track.rb in kagu-1.0.0 vs lib/kagu/track.rb in kagu-1.1.0

- old
+ new

@@ -10,11 +10,10 @@ attr_reader :added_at, :album, :artist, :genre, :id, :length, :path, :title, :year def initialize(attributes = {}) super - raise Error.new("No such file: #{path.inspect}") if File.exists?(path) && !exists? end def <=>(other) return nil unless other.is_a?(self.class) added_at <=> other.added_at @@ -82,12 +81,13 @@ def itunes_genre=(value) self.genre = html_entities_decode(value) end def itunes_location=(value) - self.path = CGI.unescape(html_entities_decode(value).gsub('+', '%2B')).gsub(/\Afile:\/\/(localhost)?/, '') - self.path = path.encode('UTF-8', 'UTF-8-MAC') if IS_MAC_OS + path = CGI.unescape(html_entities_decode(value).gsub('+', '%2B')).gsub(/\Afile:\/\/(localhost)?/, '') + path = path.encode('UTF-8', 'UTF-8-MAC') if IS_MAC_OS + self.path = path end def itunes_name=(value) self.title = html_entities_decode(value) end @@ -108,9 +108,11 @@ @length = value.to_s =~ /\A[0-9]+\z/ ? value.to_i : nil end def path=(value) @path = value.to_s.presence + raise Error.new("No such file: #{path.inspect}") if File.exists?(path) && !exists? + Kagu.logger.warn('Kagu') { "No such iTunes track: #{path.inspect}" } unless exists? end def title=(value) @title = value.to_s.squish.presence end