Archive for February, 2007

MyPlunge

Well, I finally took the plunge and joined MySpace. I was very reluctant… there's so much mediocrity on the web, and so much of it lives at MySpace. I have two initial thoughts:

  1. I've seen uglier HTML code in my life, but it was generated by Word 97; and
  2. I've seen more addictive activities in my life, but only in video games (Fallout! Tetris!) and psychoactive drugs.

You'd think that something that was designed to be personalized would have a few more CSS hooks. I managed to get the thing looking better with the help of Mike Industries' setup, which was nicely done, but jeez. When I have to write CSS rules for "table table table table td," something is very, very wrong. Would it kill them to add a few id and class attributes?

Well, it's painful, but I'll get over it. And my page will always be a safe haven from 600-pixel images, autoplaying music, animated GIFs, videos that all start playing at the same time, and high-contrast background images. Such atrocities will never be committed on my watch.


Tags: ,
Comments (1)

Audio tagging, Web 2.0-style.

I decided I want to be able to tag my audio files. Not just tagging, like with ID3 tags, but you know, tagging, like you tag a flickr photo or a del.icio.us bookmark. Web 2.0 tagging.

I have a digital music collection of close to 800 albums. There are nearly 300 different artists represented across almost 9,000 individual Ogg and MP3 files. I typically listen to this collection over the network, using DAAP (see a previous post), or occasionally through a Samba share from my Windows machine.

It's getting a little hard to find things with so much music to look through. So I've built some playlists with mt-daapd that divide things up in various ways. It goes a long way - you can specify playlists based on any combination of metadata fields, date added, filename, bitrate, etc.

There are a few problems with this approach. First, they're hard to maintain; even if your files are scrupulously tagged (I use MusicBrainz, which handles everything except, inexplicably, genre), you usually have to remember to add new things to your playlists.

Second, it's not very flexible; if you want to group music by anything other than genre (say, region of origin, or "driving songs"), you're out of luck. This issue is complicated by the perverse decision to limit genres in ID3v1 to a predetermined list of 126 (often dubious) choices.

Third, it's not portable. Your carefully constructed playlists are only available to DAAP clients accessing your share. This defeats the main reason for building audio metadata right into the files themselves.

After struggling with this for a while, it seems clear that what I really want to do is to associate small bits of arbitrary metadata with each file, so that I can create playlists based on whether those bits are present or not. And it should be up to me to determine what the groupings are. I should be able to create playlists of my wife's favorite songs, songs written by Lennon/McCartney, songs that came out while I was in high school, songs by artists from other countries, songs that I've seen performed live… anything I can think of should be possible. In other words, I want to be able to tag — and I mean Web 2.0-style, baby — my music.

So I began to commandeer the "comment" metadata field for this purpose. It works beautifully - I fill in the comment field with a space-separated list of tags for a file. In mt-daapd, and in library-based clients like Winamp, I can create a playlist based on whether a particular string occurs in the comment field. And the tags stay with the file, where they belong.

Still, it's a little daunting to tag 9,000 audio files. So — and here's the fun part — I wrote a couple of tools in Perl to help me out.

The first one doesn't actually tag anything. I use it to help me figure out what tags I might want to add to a particular artist. Given a list of artists, it will go over to last.fm and get a list of the top tags for an artist using their excellent XML services. If you don't give it any artists, it will use the name of the current directory (a convenience for me, since I'm doing all this from the command line). It's called lastfmtags, it uses LWP, and if you love the GPL, you can download it right here.

lastfmtags:
$ lastfmtags C*
Fetching tags for CAKE...
alternative
rock
indie
alternative rock
indie rock
seen live
Cake
pop
favorites
fun
Fetching tags for Cage...
Hip-Hop
hip hop
rap
Def Jux
heavy metal
underground hip hop
underground hip-hop
hiphop
Power metal
metal
...

'Nuff said. Okay, the other one is called commentify, and it's the tool I use to bend the audio comment field to my will. At its core is Audio::TagLib, which is a Perl wrapper around the nifty taglib library. It's a format-independent audio metadata library, which means that it goes and figures out what kind of audio file it's dealing with and handles each type in its own special way, so you don't have to. And it means that this script should work, not only for MP3 and Ogg, but also, apparently, APE, FLAC, and Musepack.

commentify can do five different tagging operations: set, append, delete, clear, and list. And it can act on multiple files or directories. If you give it a directory, it'll perform that operation on all files it finds underneath that directory (including all subdirectories). So it's easy to tag a whole lot of files, especially in a well-organized library. It's GPL, too, and you can get it right here.

Note that it will not attempt to preserve tag order. If it does, it's by accident. And it will not tag a file with duplicate tags.

commentify:
# set tags for all files within multiple directories
# (replaces all comment fields)
commentify -s "rock indie canadian" Arcade\ Fire/ Metric/

# add a new tag to some files
# (leaves existing tags intact)
commentify -a "favorite" dir1 dir2 file1 file2

# delete a couple of tags from some files
# (leaves others intact)
commentify -d "blah yadda" dir1 file1

# clear all comment fields
commentify -D dir1 dir2

# list comment fields for all files found
commentify -l dir1 dir2

Ah, that's good stuff. Now I think I'll go create a playlist from albums with green on the cover, bands that are side projects, and songs about cheese.


Tags: , , , , , , ,
Comments (9)

Bad Behavior has blocked 53 access attempts in the last 7 days.