Created
January 18, 2012 04:14
-
-
Save siscia/1630910 to your computer and use it in GitHub Desktop.
echonest example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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