Skip to content
This repository
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 29 lines (20 sloc) 0.51 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
#!/usr/bin/env perl

use strict;
use warnings;

use feature qw( :5.10 );

use LWP::UserAgent;
use JSON;
use URI;

my $uri = URI->new('http://www.last.fm/ajax/getResource');
my $ua = LWP::UserAgent->new;
my $json = JSON->new;

my @artists;

for(@ARGV) {
$uri->query_form(type => 'artist', name => $_);

my $response = $ua->get($uri);

if($response->is_success) {
my $data = $json->decode($response->content);
push @artists, $data;
}
}

say 'artists/' . join(',', map { $_->{resource}->{id} } @artists);
Something went wrong with that request. Please try again.