Permalink
Browse files

Script for multi-artist stations.

  • Loading branch information...
1 parent 8143ec7 commit 3085477ce55e70b3e6ee554fd99a266350731e65 Jonas Kramer committed Nov 9, 2012
Showing with 29 additions and 0 deletions.
  1. +29 −0 scripts/mastation.pl
View
@@ -0,0 +1,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);

0 comments on commit 3085477

Please sign in to comment.