2011-04-06 22:02:48 +00:00
|
|
|
# encoding: UTF-8
|
2011-04-05 22:58:11 +00:00
|
|
|
class Album < ActiveRecord::Base
|
|
|
|
set_table_name 'musicbrainz.bh_release_group'
|
|
|
|
belongs_to :artist
|
|
|
|
has_many :releases, :conditions => "release_type = 1", :order => 'date ASC, id ASC'
|
2011-04-06 22:02:48 +00:00
|
|
|
|
|
|
|
require 'iconv'
|
|
|
|
|
|
|
|
def cover artist
|
|
|
|
q_artist = CGI::escape(artist)
|
|
|
|
q_album = CGI::escape(name)
|
|
|
|
#i = Iconv.new('Windows-31J', 'UTF-8')
|
|
|
|
path = open(
|
|
|
|
'http://ws.audioscrobbler.com/2.0/' <<
|
|
|
|
'?method=album.getinfo' <<
|
|
|
|
'&api_key=b25b959554ed76058ac220b7b2e0a026' <<
|
|
|
|
'&artist=' << q_artist <<
|
|
|
|
'&album=' << q_album
|
|
|
|
).read
|
|
|
|
|
|
|
|
path.match(/<image\ssize=\"mega\">(.*)<\/image>/i)[1]
|
|
|
|
end
|
2011-04-05 22:58:11 +00:00
|
|
|
end
|