Class: Sh::Song

Inherits:
Sequel::Model
  • Object
show all
Defined in:
lib/sh_database.rb

Instance Method Summary collapse

Instance Method Details

#lookup!Object



177
178
179
180
181
182
183
184
# File 'lib/sh_database.rb', line 177

def lookup!
  begin
    return Fingerprint.identify! self
  rescue Exception
    Log.debug "Couldn't identify song from fingerprint", $!
    return false
  end
end

#to_htmlObject



164
165
166
167
168
169
170
171
172
173
174
175
# File 'lib/sh_database.rb', line 164

def to_html
  t = title
  t = "Unknown" if not t or t.strip == ""
  t = CGI.escapeHTML t
  ar = artist.name
  ar = "Unknown" if not ar or ar.strip == ""
  ar = CGI.escapeHTML ar
  al = album.title
  al = "Unknown" if not al or al.strip == ""
  al = CGI.escapeHTML al
  return "<b>#{t}</b> by <i>#{ar}</i> from <i>#{al}</i>"
end

#to_sObject



160
161
162
# File 'lib/sh_database.rb', line 160

def to_s
  return "%s, %s, %.2d - %s" % [artist, album, track_num, title]
end

#validateObject



186
187
188
# File 'lib/sh_database.rb', line 186

def validate
  errors[:path] << "must exist" unless path and File.exists?(path)
end