'Tis the Season for Shoddily Parsing XML
posted on: Monday, December 12, 2011 (6:14 pm) by Chase Stevens
Here's a little something I wrote up to download and tag a bunch of mp3s (of the Christmas song variety) from a jwplayer xml playlist. If you'd like to download from other playlists, simply change xml_url (and perhaps localdir, if you'd like to download your music to somewhere a little more accessible). You'll need to have this ID3 library installed.
xml_url = "http://pinochan.net/overbooru/xmas/playlist.xml"
localdir = "C:\\Xmas_Music"
webdir = xml_url[::-1][xml_url[::-1].find('/'):][::-1]
print "Downloading to", localdir
print "Creating download directory", localdir
xml_page = urllib2.urlopen(xml_url)
print "Error opening playlist URL."
print "Parsing XML"
xml = xml_page.read().replace("\t","").replace("\n","")
tracks = xml.split('
Tags: code, jwplayer, metadata, mp3, music, programming, python, tagging, xmas, xml