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:


BEGIN {
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.

Not “Tivoted”

It’s timely that Jeff Jarvis, Fred Wilson, and Om Malik have started kvetching about how to save TiVo. Just last night, I downloaded the TiVo Home Media Engine SDK to see if there was something worthwhile tinkering with. To be honest, I was kind of shocked at limited functionality provided by the SDK.

I was originally interested in creating a nice little application to destroy the TV broadcast model – you know, for fun! When I heard the TiVo SDK was based on Java, I figured I’d have everything I needed. I knew that the TiVo SDK didn’t allow video playback, but I thought I would be able to use the Java Media Framework to render Flash content. With a little tinkering, I figured I should be able to stitch together a simple app to push vodcasting a little closer to reality. Boy was I wrong.

The whole approach taken by the TiVo HME SDK is extremely limiting. Basically it’s a client-server approach that requires an application to live on a separate PC running the application, which sends commands over TCP/IP to the receiver (i.e. the TiVo box). While an application can stream audio or send images to the TiVo, no capabilities are provided for displaying video. Oh, I suppose if you were really desperate for this capability, you could hack together a solution that renders frames to a Graphics2D context, which could then be rendered as an image on the TiVo – but I’m guessing the performance would be horrible. And, anyway, as a developer I’m really not interested in hacking together codecs, I’m interested in writing applications.

I guess what bugs me about the SDK more than anything is that TiVo seems to be operating under the delusion that erecting fences around what a developer can access on a TiVo is a good idea. If TiVo is really serious, they need to look at allowing developers on the device itself (legitimately, I mean, as opposed to the current method for extending TiVo’s capabilities). Of course, TiVo seems to be happy enough to snub the cable companies, but not ballsy enough to really take on the established model – maybe we’ll have to wait for Akimbo for that?

C’mon TiVo, if you want a million flowers to bloom, you’ve got to give us everything! Give us a method to put code on the device (I mean, seriously, what average consumer is going to run stuff on another machine). Let us manipulate data! Let applications like mGrok (Disclosure: the guys behind mGrok are friends of mine) get access to raw MPEG data and build applications that enable people to get more out of their TiVo, their recorded shows, or content downloaded from the net. If you really want to beat Windows Media Center and continue to lead the industry you created, you’re going have to provide unlimited access (maybe you should follow Scoble’s suggestion and allow media-centric companies like Orb to solutions on top of your platform that don’t require yet another application on their home computer).

If you’re not prepared to bet all of your chips, it’s time to get out of the game.