Parsing .asx playlist files in python

Michael L Torrie torriem at
Fri Sep 28 21:29:30 MDT 2007

So I'm trying to parse asx playlist files in python and then, using
player, download each stream in the playlist and dump it to a wav file
which I will encode to mp3 or ogg.  I've run into problems.  Rather than
brute-force parse the playlist, I thought I'd just use an XML parser,
since it appears to be xml. Turns out it is not.  It's
almost-but-not-quite-xml.  Totem appears to have a generic playlist
parser in library form that I can use that would be very slick, since it
handles all the urls automatically.  There's an example program in
python that shows how it works:

Sadly, though, totem's parser appears to either be thinking the playlist
really is xml, or else they expect the playlist to be a bit more
well-formed than it is.  Because totem's parser fails miserably for
NPR's playlists.  Even Totem the player won't play them.  However
mplayer and xine will (must have their own parsers), however those
parsers aren't in library form for use from python.

Here's an example that fails on totem on my machine:
$ totem
line 2: parser error : EntityRef: expecting ';'
Entity: line 2: parser error : EntityRef: expecting ';'

Besides ad-hoc parsing the thing, does anyone have any better ideas?



More information about the PLUG mailing list