So, you know I’ve been teaching myself Perl using a couple of books:
I feel like I’m really making progress… I downloaded a theme for Bowtie (a free desktop accessory that allows you to see and control either iTunes or Spotify) called Lux by Ryan Christensen. I was really getting off on how it pulls images from Last.FM to fill the background of the theme.
I opened the theme file to see how it was written and saw a relatively simple call to Last.FM’s API. So, now I had to give it a try.
As you know, this isn’t just as easy as calling the method. There is a lot of setup, so I went over to cpan.org and did a search for ‘Last.FM’. Sure enough, I found: Net::LastFM. I downloaded the file, but found it had prerequisites.
So I cracked open the books (virtually, thank heaven for PDF’s and the ability to search them!) and searched for Perl Modules. I found a great little Perl script called ‘cpanm‘ which will painlessly install Perl Modules.
So I installed ‘cpanm’ with a little head scratching since it needed:
--sudo
added to the
perl - --self-upgrade
part of the
curl -L http://cpanmin.us | perl - --self-upgrade
Once I got past that part, I was golden. Net::LastFM was installed and I was ready to test.
I used a sample described in both the Sams book and the documentation of the module and created:
#!/usr/bin/perl
use Net::LastFM;
use Data::Dumper;
my $lastfm = Net::LastFM->new(
api_key => '...',
api_secret => '...',
);
my $data = $lastfm->request_signed(
method => 'artist.getImages',
artist => 'Kate Bush',
limit => '10',
autocorrect => '1',
order => 'popularity',
);
print Dumper $data;
It doesn’t do much more than show the data returned from Last.FM, but that’s a start and I’m pretty excited that I was able to get that far without too many problems.
Now, if only there was a way to take the image I get and save it to disk.
I know, there is probably a Module that can do that. I’ll have to dig around a little bit more. Still…
