Album covers for your SliMP3

What's this all about?

I love my SliMP3 player. It's easily one of the coolest electronic gadgets I have ever bought. One of the nice things about it is that it includes a web interface to control the player, including all the playlists and such. This feature also has the ability to show the album cover in the web interface, if an image file is in the same directory as the mp3s. Looks something like this (note that this image is scaled down to 800x600 to be of reasonable size).

The problem I ran into was that I had a huge number of CDs and wasn't about to spend an insane amount of time scanning in every album cover. By an odd coincidence, at this same time, I discovered Amazon's SOAP interface to their database. A solution quickly evolved to meet my problem. It's possible to query Amazon's database for a given title, and pull down the image for the album cover from their site.

This script will run over your mp3 directory, look at the ID3 tags of the mp3s it finds, and will perform several different types of searches on the Amazon database to find the closest matching album. It will then download the album cover, if it's available, and place it in the corresponding directory for that album.

What does it require?

At the very least, you'll need to have a fairly recent version of Perl running on your system. This code was tested with both version 5.6.1 and 5.8.0 and worked fine.

You'll also need a few perl modules. Specifically: SOAP::Lite, and Image::Info. While these links go to the versions of the modules I used for testing and deploying, you generally are safe with installing whatever the latest version is. You'll also need a few other modules, but those should be a part of your standard perl install and of your SlimServer install.

The easiest way to get the modules (if you're in a Linux or an OSX environment) is open up a command line terminal, and then become the root user. Then type in:
perl -MCPAN -e shell
If this is the first time you've ran the CPAN module, it'll ask you some questions to get an initial configuration. Once that's done, from the CPAN prompt, type in:
install Image::Info SOAP::Lite
CPAN will then ask you some questions about installing necessary dependencies, and then install all the necessary modules for you

If you're installing this program in a Windows environment, definitely check out the article on Automated installation with PPM for a good guide as to how to perform the above in Windows. Note that the latest version of Active Perl comes with SOAP::Lite and LWP already installed.

Charles Stantons adds his suggestion for how to get this to run in a Windows environment:

I got it to work in Windows XP and just thought I send on some notes.

1. Install Make Cover in c:\amazon_image
2. Install Perl 5.8 (I got all sorts of "@INC" errors with 5.6) at c:\perl
3.Copy AmazonMusicImage.pm and ReadTag.pm from the c:\amazon_image directory to c:\perl\site\lib
4. Using ppm (c:\perl>ppm), install Image::Info
5. Run it from c:\perl with this example command: c:\amazon_image\make_cover.pl -p "c:\program files\slimserver\server" -m "k:\library" -d

Note - "c:\program files\slimserver" will not work.

How do I get it to work?

NOTE: If you do not have proper ID3 tags in your MP3s, this code will not work very well for you. If you need help in getting your mp3 collection organized with id3 tags, I highly recommend The MusicBrainz Tagger. It's hard to describe how cool of a tool it is -- check it out.

After you've downloaded and extracted the files, you'll see in the newly created directory several files. The one you're interested in is called make_cover.pl.
Before you do anything else, edit that file and make sure the very first line (the one that reads #!/usr/bin/perl -w, actually points to the proper perl location on your system.

That's all the setup you need to do. Just run the make_cover.pl and it will tell you the options that it needs, and once you got those done, run the script. It'll display an incremented "#" status indicator to let you know it's still working, and after some time (about 10 minutes on my system for over 600 CDs and downloading over DSL -- obviously this will be much slower if you're on a dial-up modem), you'll have a cover.jpg (or whatever you specified on the command line) file in every directory where the code could find a reasonable match. I can gurantee that it won't be 100% accurate (unless your ID3 tages are simply pristine and match up to what Amazon thinks they should be), but I am finding that I am hitting between 75% and 85% accuracy with my CD collection.

Random observations made while developing this code

  • My ID3 tags were in much worse shape than I thought when I started this project. Especially live albums have so much variance in their naming that it's practically impossible to consistently identify them.
  • Classical albums are pretty much out of the question with this code because of how Amazon identifies composers and album names. I'd like to fix that in the code later, but it's complex enough that I am not going to mess with it unless someone has a real need for it.
  • Ditto for albums that are listed with more than one performer/composer, i.e., Miles Davis and John Coltrane. The way that type of data is returned from Amazon is inconsistent. The code deals with it -- but in a rather brute force manner which is surprisingly effective, but it's not perfect.
  • I have no idea how to manage soundtracks and "various artists" types of compilation. There does not seem to be any standard either in the ID3 tags, or in how Amazon returns the data that makes parsing this type of data possible.
  • If you have proper track numbers in the ID3 tag, this code will be much more accurate for you, since it can match up on specific songs to decide if an album is a "close enough" of a match when the album/artists are not an exact match.
  • I really wanted this code to search more than just Amazon. Specificaly, AllMusic.com has fantastic music data. Unfortunately their terms of service state: "You may not distribute any Material to others, whether or not for payment or other consideration, and you may not modify, copy, frame, cache, reproduce, sell, publish, transmit, display or otherwise use any portion of the Material. You may not scrape or otherwise copy our Material without permission. You agree not to decompile, reverse engineer or disassemble any software or other products or processes accessible through the AMG Websites, not to insert any code or product or manipulate the content of the AMG Websites in any way that affects the user's experience, and not to use any data mining, data gathering or extraction method." If you know of any legal way to query AllMusic.com, please let me know.

How do I get it?

The latest version is always available here and the latest changes are available here.

I have a question/suggestion/bug report for you...

Questions, suggestions, ideas, and patches can be directed to the bug tracking system that's been set up. There you can enter bug requests, make suggestions, or ask for enhancements. Please use it -- that is a much more reliable way of getting things done rather than emailing me.
If you need to get a hold of me personally, I am at: victor AT victorland.com. De-spamify the address accordingly.

Stuff that still needs to get done

  • I'd really like to make this tool easier for Windows users -- any suggestions are welcome
  • If anyone wants to write better documentation and/or a better webpage, their help would be gladly accepted
  • Suggestions on how to improve the accuracy of Amazon searches would be great