1
0
Fork 0
oldhaven/app/models/artist.rb

20 lines
567 B
Ruby
Raw Normal View History

2011-04-03 18:32:27 +00:00
class Artist < ActiveRecord::Base
set_table_name 'musicbrainz.bh_artist'
2011-04-05 22:58:11 +00:00
has_many :albums, :conditions => "release_type = 1", :order => 'year ASC, id ASC'
2011-04-10 06:17:06 +00:00
2011-04-03 18:32:27 +00:00
def self.getByName(name)
Artist.first(:conditions => ['name = ? AND id=credit_id', name], :order => 'rating DESC')
end
2011-04-10 06:17:06 +00:00
def self.getLastFmAutocomplete(query)
return nil if query.nil? or query.strip.empty?
json = ActiveSupport::JSON.decode(open(
'http://www.last.fm/search/autocomplete' <<
'?q=' << URI.escape(query)
).read)
return nil if json.empty? else return json
end
2011-04-03 18:32:27 +00:00
end
2011-04-10 06:17:06 +00:00