Skip to content

Instantly share code, notes, and snippets.

@trapd00r
Created March 14, 2010 12:58
Show Gist options
  • Save trapd00r/331950 to your computer and use it in GitHub Desktop.
Save trapd00r/331950 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
# Find similar artists POC
# trapd00r 2010
use strict;
use warnings;
use Audio::MPD;
use LWP::Simple;
my $mpd = Audio::MPD->new;
my $artist = shift // $mpd->current->artist // undef;
my $url = "http://ws.audioscrobbler.com/1.0/artist/$artist/similar.txt";
sub fetch_similars {
if($artist) {
my @fetched = split/\n/, get($url);
print "Artists similar to $artist:\n\n";
s/.+,//g for(@fetched);
foreach my $sim(@fetched) {
print $sim, "\n";
}
}
else {
print "ID3 tag ARTIST missing\n";
exit 0;
}
exit 0;
}
&fetch_similars;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment