1#!/usr/bin/perl 2############################################################ 3# mp3 artist_name 4# Christopher Boumenot <boumenot+na@gmail.com, 2009 5############################################################ 6 7use strict; 8use warnings; 9 10#use Log::Log4perl qw(:easy); 11#Log::Log4perl->easy_init($INFO); 12 13use Net::Amazon; 14use Net::Amazon::Request::MP3Downloads; 15 16die "usage: $0 artist\n(use 'Hand in My Pocket' as an example)\n" unless defined $ARGV[0]; 17 18my $ua = Net::Amazon->new( 19 associate_tag => $ENV{AMAZON_ASSOCIATE_TAG}, 20 token => $ENV{AMAZON_TOKEN}, 21 secret_key => $ENV{AMAZON_SECRET_KEY}, 22 max_pages => 1, 23); 24 25my $req = Net::Amazon::Request::MP3Downloads->new( 26 title => $ARGV[0], 27); 28 29 # Response is of type Net::Amazon::MP3::Response 30my $resp = $ua->request($req); 31 32if($resp->is_success()) { 33 print $resp->as_string, "\n"; 34} else { 35 print $resp->message, "\n"; 36} 37