7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/sh_cover_art.rb', line 7
def CoverArt.get_cover song
artist, album = song.artist.name, song.album.title
path = "#{$cover_dir}/#{artist.to_md5}_#{album.to_md5}"
if Ping.pingecho("audioscrobbler.com", 5) and not File.exists?(path)
doc = lastfm("album.getInfo", {:artist => artist, :album => album})
img_url = REXML::XPath.first(doc, '//image[@size="extralarge"]').text
if img_url
open(path, 'w') do |output|
open(img_url) do |input|
output << input.read
end
end
end
end
if File.exists? path
return path
else
return nil
end
end
|