Album pics from last.fm
This commit is contained in:
parent
2f611742ba
commit
a9b4a46c59
|
@ -1,5 +1,23 @@
|
|||
# encoding: UTF-8
|
||||
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'
|
||||
|
||||
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
|
||||
end
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<% @artist.albums.each do |album| %>
|
||||
<% unless album.releases.empty? %>
|
||||
<div class="album">
|
||||
<div class="pic"></div>
|
||||
<div class="pic"><img src="<%= album.cover(@artist.name) %>" width="250" height="250" alt=""/></div>
|
||||
<h3 class="name"><%= album.name %> <%= (album.year ? album.year : '') %></h3>
|
||||
<%
|
||||
releases = album.releases
|
||||
|
|
|
@ -41,7 +41,7 @@ body {
|
|||
.album .name {
|
||||
display: block;
|
||||
float: left;
|
||||
width: 400px;
|
||||
width: 450px;
|
||||
font-size: 1.5em;
|
||||
margin: 0 0 0.5em 0;
|
||||
/* background-color: yellowgreen;*/
|
||||
|
@ -50,7 +50,7 @@ body {
|
|||
.album .tracks {
|
||||
display: block;
|
||||
float: left;
|
||||
width: 400px;
|
||||
width: 450px;
|
||||
margin-bottom: 1em;
|
||||
/* background-color: lightblue;*/
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue