I like Spotify. I like Java. So I combined them. Here’s a Java client for the new Spotify metadata API: JSpot
This client lets you do things like search for a track by name and get the Spotify ID for the track so you can play the track in Spotify. This is useful for all sorts of things like building web apps that use Spotify to play music, or perhaps to build a Playdar resolver so you can use Spotify and Playdar together.
Here’s some sample code that prints out the popularity and spotify ID for all versions of Weezer’s ‘My Name Is Jonas’.
Spotify spotify = new Spotify(); Results<Track> results = spotify.searchTrack("Weezer", "My name is Jonas"); for (Track track : results.getItems()) { System.out.printf("%.2f %s \n", track.getPopularity(), track.getId()); }
This prints out:
If you have Spotify and you click on those links, and those tracks are available in your locale you should hear Weezer’s nerd anthem.
You can search for artists, albums and tracks and you can get all sorts of information back such as release dates for albums, countries where the music can be played, track length, popularity for artists, tracks and albums. It is very much a 0.1 release. The search functionality is complete so its quite useful, but I haven’t implemented the ‘lookup’ methods yet. There some javadocs. There’s a jar file: jspot.jar. And it is all open source: jspot at google code.
#1 by Oscar Celma on November 3, 2009 - 10:54 pm
Nifty!
BTW, while waiting in the Vancouver airport I was doing some tests ( http://www.iua.upf.es/~ocelma/1001-spotify-albums/1001_spotify_albums.html ) using this python library:
http://pypi.python.org/pypi/spotimeta/0.1
(by Rune Halvorseon)
So, now there’s at least a java and a python version.
I’m pretty sure soon there will be more versions (for PHP, Ruby, Modula-2, Prolog, etc. :-)
Cheers, Oscar