Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- # http://developer.echonest.com/docs/v4/song.html#identify
- # wget https://github.com/echonest/echoprint-codegen
- # cat README.md
- #----------------------------------------------
- use LWP::Simple;
- use JSON qw( decode_json );
- use JSON::Parse;
- use Data::Dumper;
- use strict;
- use warnings;
- system('./codegen.Linux-i686 "'.$ARGV[0].'" 30 30 > /tmp/sng.tmp');
- open FILE, "/tmp/sng.tmp" or die $!;
- my @file_lines = <FILE>;
- close FILE;
- my $decoded_json = decode_json( $file_lines[1] );
- my $mus_code = $decoded_json->{'code'};
- print "code: ", $mus_code, "\n";
- my $trendsurl = "http://developer.echonest.com/api/v4/song/identify?api_key=FILDTEOIK2HBORODV&code=".$mus_code."";
- my $json = get( $trendsurl );
- die "Could not get $trendsurl!" unless defined $json;
- $decoded_json = decode_json( $json );
- print Dumper $decoded_json;
- print "artist_name: ", $decoded_json->{'response'}{'songs'}[0]{'artist_name'}, "\n";
- print "title: ", $decoded_json->{'response'}{'songs'}[0]{'title'}, "\n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement