Skip to content

Instantly share code, notes, and snippets.

@siscia
Created January 18, 2012 04:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save siscia/1630910 to your computer and use it in GitHub Desktop.
Save siscia/1630910 to your computer and use it in GitHub Desktop.
echonest example
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package echo_nest;
import com.echonest.api.v4.*;
import java.io.File;
import java.io.IOException;
/**
*
* @author leonardo
*/
public class Main {
/**
* @param args the command line arguments
* @throws EchoNestException
* @throws IOException
*/
public static void main(String[] args) {
try{
File file = new File(args[0]);
if(!file.canRead()){
printUsage();
System.out.println("Insert a valid path!");
}
EchoNestAPI echoNest = new EchoNestAPI("JRZSJUMBK8VOOP0L2");
Track traccia = echoNest.uploadTrack(file, true);
traccia.waitForAnalysis((60*1000)/2);
System.out.println("ID: "+traccia.getID());
System.out.println("Artista: "+traccia.getArtistName());
System.out.println("Titolo:"+traccia.getTitle());
} catch(EchoNestException ex){
} catch(IOException ex){
} catch(ArrayIndexOutOfBoundsException ex){
printUsage();
}
}
public static void printUsage(){
System.out.println("Usage: java -jar /path/to/this/jar/file/echo_nest.jar file.mp3");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment