Exporting iTunes Playlists to Tivo

This is a little thing that’s been bugging me since we got our TiVo a while back, but I never got around to solving it – exporting my music playlists from iTunes to TiVo. TiVo’s jukebox interface is simply horrendous, so playlists are an absolute must, unless you like scrolling through pages of your music collection. iTunes makes matters worse in that it doesn’t allow you to export M3U-formatted playlists, the format TiVo requires.

Sigh. A little shell scripting and awk is all that’s required to resolve this problem in short order. Here’s an awk script called m3u-ify.awk to convert an iTunes playlist (exported as plaintext) to an M3U playlist:

FS = "\t"
print "#EXTM3U"
if (match($27, /\.mp3/))
time = $8
name = $27
location = $27

# Figure out the location from the absolute location
# that iTunes exports. Note that we remove the '- ' from
# the location, which iTunes seems to add erroneously.
# Using 'sub' is not ideal, but gensub seems flakey in
# my version of gawk, otherwise I'd use the following:
# location = gensub(/D:\\Music\\\(.*\\.*\\[0-9]*\) -\(.*\)\.mp3/, "\\1\\2", "g", location)
sub(/D:\\Music\\/, "", location)
sub(/ - /, " ", location)

# Find the name of the song - this regex is giving
# me problems in Cygwin with gawk, so I coded an
# alternate way to get to the normalized song name
# name = gensub(/D:\\Music\\.*\\.*\\[0-9]* - \(.*\)\.mp3/, "\\1", "g", name)
sub(/D:\\Music\\.*\\.*\\/, "", name)
sub(/\.mp3/, "", name)
sub(/[0-9]* - /, "", name)

print "#EXTINF:"time","name
print location

Note that my music collection is located in D:\Music (which needs to be stripped out of the file location to create the M3U file) – you will have to alter this script if to the location of your iTunes music folder.

To use the script, you’ll need awk installed on your machine (for those of you using Windows, you might try grabbing a copy of Cygwin) . To convert a playlist to M3U:

  1. Select a playlist in iTunes, export it as a text-formatted playlist (input.txt) to a folder containing the above script
  2. Open a shell prompt, go to the folder where you saved the text-formatted playlist
  3. Run awk -f m3u-ify.awk input.txt > output.m3u

You’ll now have an M3U-formatted version of your playlist. If you really want to be fancy, export all your playlists at once, and then generate a batch shell script to process them all at once by running ls -1 *.txt |sed -e 's/\(.*\)\.txt/awk -f m3u-ify.awk \"\1.txt\" > \"\1.m3u\" /g'>batch.sh. This will generate a shell script called batch.sh that will process all the text playlists in once go.

Note: I point TiVo Desktop to my iTunes folder directly – I’m not sure if this affects file location specified in the M3U or not. Your mileage may vary.

An IM Client That Works

I’m not a huge IM user, but as good as Trillian is for managing competition on multiple fronts, there’s still a gap to be filled in the IM world. Yet for all the IM competition, could Meebo or Wablet, or one of the other IM competitors please add the one feature I need? What do I want? Simple. I want profile-based presence for my instant messaging clients.

What I am talking about? I want the ability to set my presence information independantly for different sets of users. When I’m at work, my IM client should only show me as available to my work colleagues and select close friends (such as my wife), so I’m not randomly interrupted when I’m at work. Similarly, when I’m at home, my IM client should only show me as available to my personal friends, so I’m not interrupted by co-workers who assume that I’m always available. I shouldn’t have to have separate IM accounts for work and home.

Maybe the IM services aren’t flexible enough to enable this. But as a user, I just don’t care about those details.