Hack 99 Add Cover Art to Your Digital Music Collection


Add cover art back into your music experience with MP3 Piranha.

If you've moved from listening to CDs to listening to MP3 files on your computer, you're probably missing some of the fun of CDs. MP3 files don't provide the original album cover art or release date information. Using Amazon's Web Services, a tool from CapeScience (http://www.capescience.com) can add some extra information while you're browsing your MP3 files.

MP3 Piranha (http://www.capescience.com/piranha/) is a Java application that queries Amazon for information about your digital music files. MP3s store metadata in ID3 tags (at the end of the MP3 file) that contain a file's title, artist, album name, release date, genre, track number, and so on. This is the way that many MP3 players automatically know the track name, artist name, and other information about the song.

The first step in developing Piranha was to generate a Java client from the Amazon WSDL file using Cape Clear Studio. WSDL files are machine-readable XML files that describe all of the SOAP methods available at a particular service. This provided the skeleton code, which was then modified to incorporate a graphical user interface. The client uses Amazon's SOAP interface to invoke Web Service methods.

In addition to AWS, MP3 Piranha relies on an open source Java library called Java MP3Info. MP3Info is a set of Java classes that can read from and write ID3 tags. More information on this library can be found at http://sourceforge.net/projects/mp3info/.

The Cape Clear-generated clients create a proxy object, which makes it easy to call Web Service methods exposed by Amazon:

//create a client proxy
AmazonSearchBindingClient client = AmazonSearchBindingClientFactory.[RETURN]
create(  );

Using Piranha, you can browse to an MP3 file using the client provided. Piranha reads ID3 metadata from the file and queries Amazon for the artist information found in the tag, supplying the other parameters required by Amazon's ArtistSearch method:

//perform an ArtistSearch
ArtistInfo artistInfo = client.ArtistSearchRequest(new ArtistRequest[RETURN]
(artist, page, "", associateId, "lite", devToken, ""));

Alternatively, you can search for an artist by typing the artist's name into a text box.

Each album that the artist has recorded is downloaded at once and stored in a Java list. Storing all the information on the client side from the outset eliminates the need for sending further queries to Amazon about that artist. The list contains information such as the album title, release date, and URL to the album cover art on Amazon's site. All this data is used to build a table that can be sorted in various ways. For example, you could view an artist's albums in alphabetical order (as in Figure 6-15) or chronological order by release date.

Figure 6-15. MP3 Piranha list sorted by album title

In addition, when you select an item in the table, Piranha fetches the cover art for the album and displays it. The cover art image also acts as a link to the purchase page for the item. Clicking on it will open the purchase page in your default browser so that you can get more information on the title or buy it directly from Amazon.

Also, when you select an album in the table and click the "view albums similar to" button, Piranha performs a similarity search based on the ASIN for that product:

//perform SimilaritySearch
SimilarInfo similarInfo = client.SimilaritySearchRequest(new [RETURN]
SimilarityRequest(asin, "", associateId, "lite", devToken, ""));

By joining together media file metadata with Amazon's Web Services, MP3 Piranha has added a new way to browse your music files and potentially find new music in the process.

?Chris McGarel