October 5th, 2008

My iTunes library is pretty close to perfectly manicured, with 90% or more of all tracks being complete albums with complete metadata and album artwork.

Except genre. There really is no canonical source of genre information on the internet, because bands tend not to self-categorize.

So, a problem arose: Lots of music, little (accurate) genre information. My solution was to harness the power of the crowds to pull what I could from Last.fm

Conveniently, Last.fm provides a surfeit of XML feeds for their data. Because Last.fm doesn’t track genre, tags have become a sort of de facto stand-in.

I whipped up a hybrid AppleScript-Ruby application that will take the selected track (or tracks) in iTunes, find the artist, and then set all tracks by that artist to the most popular Last.fm tag.

It’s pretty fast, and it works decently. At least, it’s the best I could think of without manually spending hours updating every artist.

I’m making the script available here for public use. Please note that I have only done limited testing, but it works for me. Always back up your iTunes library on a regular basis. I am not responsible if this script decides that all of your music deserves to be labelled Prog Rock.

To use it, drag Fetch Genre from Top Last.fm Tag.app to ~/Library/iTunes/Scripts (create it if it doesn’t exist). Then select a track from the artist you want to update, and select Fetch Genre from Top Last.fm Tag from the Scripts menu in iTunes.

The source is not protected and you are welcome (and encouraged) to make changes. If you do, please just provide credit and a link here.

Known Issues

Download “Fetch Genre from Top Last.fm Tag” (28KB)