Class: Sh::Song

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

Instance Method Summary collapse

Instance Method Details

#lookup!Object



187
188
189
190
191
192
193
194
# File 'lib/sh_database.rb', line 187

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

#to_htmlObject



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

def to_html
  t = title
  t = File.basename(path) 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



169
170
171
172
# File 'lib/sh_database.rb', line 169

def to_s
   = [artist, album, track_num, title || File.basename(path)]
  return "%s, %s, %.2d - %s" % 
end

#validateObject



196
197
198
# File 'lib/sh_database.rb', line 196

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