-
Notifications
You must be signed in to change notification settings - Fork 43
Fetch & display album art on Mac OS X with perl script & geektool
Here's a tip to anyone trying to accomplish this on OS X
np-cmd = wget -O /path-to/albumart.xml "http://ws.audioscrobbler.com/2.0/?method=album.getinfo&api_key=(your api key here)&artist="%a"&album="%l"&autocorrect=1" && perl /path-to/perlalbumart.pl
Perl Script:
Note: i couldn't make the whole section below show up as code, had to surround each line since comments with # wouldn't display otherwise:
#!/usr/bin/perl
# use module
use XML::Simple; use Data::Dumper; use File::Fetch;
# create object
$xml = new XML::Simple;
# read XML file
$data = $xml->XMLin("/path-to/albumart.xml");
# print output
$image=$data->{album}->{image}->[2]->{content};
$ff = File::Fetch->new( uri => $image ); my $where = $ff->fetch( to => '/path-to-album-art-folder/albumart/' );
use File::Copy; move ("/path-to-album-art-folder/albumart/$ff->{file}", "/path-to-/albumart/album.png") or die "Copy failed: $!";
# end perl script
Then in geektool, create a display image geeklet to that album.png, and refresh every 1 seconds. Doesn't matter if the image is actually jpg/gif as geektool detects proper format.
Notice the album art on bottom left, and track info on top in menu bar which i display with a "cat" of now-playing file refreshing automatically