Once upon a time, digital audio files didn’t carry any information about their creators. No artist name, album, track number – nothing. Naturally, this led to a lot of redundant effort keeping music organized and contextual. In 1996, a little sidecar called ID3 came along, essentially providing a space for textual information about audio that hitched a ride within an MP3 file. While it was a victory for the preservation of metadata, it had its limitations, not least of which was a stodgy implementation of a Genre field.

The original sidecar had only 35 bytes of space to work with. Maximizing room for artist, album, and everything textual meant reducing genre to a single category, which was converted to an integer so that it only occupied a single byte in the overall sidecar. The original ID3 implementation only contained 80 pre-determined options for the genre field.

Which leads to the dilemma:

  • No song is of a single genre, but rather many. What good is reducing music to a single container anyway?
  • What is rawk to one listener is britrock to another, is emo to another and is shoegaze nu-wave to another.

For this reason, the metadata available in the Genre field is of little use to anyone. You can’t just listen to Alternative or Electronic and expect to have a consistent listening experience. In a sense this parallels the problems with the RIAA and big label music, but I’ll leave that tangent for another day…

We’re not stuck in that bucket anymore. One of the advantages of having millions of people tagging music through services like last.fm is that we now have a much more nuanced voice in describing our music. Let’s face it, it’s not very helpful to call Boards of Canada an electronic group. In fact they are ‘electronic ambient idm chillout downtempo trip-hop indie Warp experimental Scottish chill.’ (according the leading tags from last.fm)

Services like last.fm, Pandora and imeem are popular because they use these tags to create radio streams that, unlike most terrestrial American radio, people enjoy listening to.

A couple years ago, before Pandora was available, I realized that I wasn’t listening to the majority of the music I owned; when I wanted to listen to music I usually thought of an artist rather than a type of music. In an effort to fix this, I took a day off attempting to create iTunes playlists that suited various musical needs. I tried to create a party mix. I tried to create a mix reminiscent of the 90’s or the 60’s. I tried to create an ambient electronic music group that I could listen to while working. Given the size of my library, it was tedious stuff, and never felt a step closer to being finished.

Yesterday I realized there’s a better solution: last.fm’s AudioScrobbler data service provides a way of retrieving tags for any given artist. The rest is creating a way of integrating that with my iTunes library. I did some searching and found that Wes Rogers’ Last.fm Tagger accomplishes a great deal of what I was hoping to do. It’s limitation was that it only took the foremost tag from last.fm and set that into the Genre field.

I’ve modified his script so that it compiles up to 20 tags, given a popularity threshold, and places them as a string into the Grouping field. Just select whichever files in iTunes you’d like to add the tags to and run the Ruby script (If you’ve selected thousands it may take a while!) After that, you activate the Grouping column in iTunes and then search for whatever you’re in the mood for. You can search for two or more genres to refine your search. And because users also often tag with context other than genre (where the music is from, speed, male/female vocalists) this really expands the boundaries of your search. It’s a bit like bringing the benefits of online radio to your local music collection.

Here’s to Wes for the MIT license, last.fm for AudioScrobbler, and the music taggers!

Download iTunes Multi-Genre Tagger v0.5.

Important Note: This will OVERWRITE whatever information is in the Grouping field of your music files. This field is nearly always empty, but you should check that nothing important is there before running this script. You will need a bit of terminal savvy and Ruby to be installed on your system in order to build the tags.

UPDATE: There’s now a newer version, and I’ve created a separate project page for it. As of version 0.6, it’s now a standalone OS X application (though the Ruby source is included for use on other platforms).

7 Responses to “Using Ruby to migrate last.fm tags to iTunes”

  1. Chris Sharp Says:

    Nice article in general but….

    “Services like last.fm, Pandora and imeem are popular because they use these tags to create radio streams that, unlike most terrestrial American radio, people enjoy listening to.”

    I think you misunderstand imeem somewhat, imeem is more like ‘youtube for music’ – upload your favorite music and then anyone can listen to it. There’s no radio streams, users can listen to anything they want on demand (unlike pandora and last.fm).

    And yes. as a club DJ I can agree that the genre classification of electronic music is an art which shares much in common with species classification by genus, phenotype and other words which I barely remember from biology many years ago.

  2. bcdef Says:

    Thanks Chris. Indeed what you say is very applicable. imeem is trying to fit a niche that will create a userbase.

    What I think is the forgotten dilemma is encapsulated in your last paragraph. If electronic music has distinctions (revise: deserves) then it is very important that we, as consumers of music, declare in as short as sorts as possible what we feel about the music. From there we move on…

  3. Dan Says:

    What’s off though is that if the user is likely to listen to something on demand, isn’t it likely that it’s already in their collection? I don’t use last.fm to listen to what I already know about – I use it to discover music I haven’t heard.

    I’m looking forward to trying this script out and I hope it foreshadows more interesting ways to use Audioscrobbler’s tags. I think what would put it over the top is not have it tag a track in iTunes with the public tags, but to go in and lookup the tags I already use with those tracks. That way the tags are specific to the user.

    Perhaps the next step is to sync the user’s activity in their music player with Last.fm (tag sync, or something like that)…

  4. bcdef Says:

    Hey Dan,

    I agree that last.fm is a discovery device, to which this script isn’t about to replace. What I hope to use this for is to re-discover things that I have but forgot about within my own collection.

    And if it really will put it over the top for you, what you’re asking is a three-line change in the code for the Multi-Genre Tagger. Just change the request stub from:

    http://ws.audioscrobbler.com/1.0/artist/#{URI.escape(CGI.escape(@name))}/toptags.xml

    to:

    http://ws.audioscrobbler.com/1.0/user/subtonic12/artisttags.xml?artist=#{URI.escape(CGI.escape(@name))}

    … and then change the two instances of ‘toptags’ to ‘artisttags’.

    I haven’t tried this but there should be no reason why this wouldn’t copy your personal last-fm tags into your Grouping field in iTunes.

    A sample of the data request: http://ws.audioscrobbler.com/1.0/user/subtonic12/artisttags.xml?artist=Squarepusher

  5. Dan Says:

    Cool.

    Although, the more I think about this the more I think that this stuff should really live in the comments field and not in the grouping field. Grouping is usually used for classical music.

    What if there were a way to tag the currently playing iTunes track with something like a Quicksilver trigger? For example, if you could add append a text string to the comments field (“Text” – “Append To” – “Comment Field of Currently Playing iTunes Track)”. You could build smart playlists the same way with the comment field data and leave the grouping field for more specific purposes.

  6. Dan Says:

    This comes close -
    http://www.dwipal.com/itunes.htm

  7. Steve Moser Says:

    I did something very similar except with applescript. Check it out.

    http://stevemoser.wordpress.com/2008/12/26/lastfm-folksonomy-itunes-applescript/

Leave a Reply