What I'd like to do is take an iTunes playlist and export certain
ID3 elements of each track to an xml file. Does anyone know how to
do this?
What's the structure of the XML file, and which ID3 tags? Anyway, the
following Python script outputs the name, album, artist and duration
for each track in the named playlist. The template markup/logic can
be modified to suit. You'll need to install the appscript package
from my site in order to use it.
======= START SCRIPT =======
#!/usr/bin/env pythonw
import os.path, sys
from appscript import *
from HTMLTemplate import Template
def render_track(node, (name, artist, album, duration)):
node.name.content = name
node.album.content = album
node.artist.content = artist
node.duration.content = str(duration)
#######
# Main
def write(path, txt):
f = open(os.path.expanduser(path), 'w')
f.write(txt.encode('utf8'))
f.close()
(Note: it's a bit of a cheat since HTMLTemplate isn't a proper XML
templating engine, but as long as tag names are all lowercase there
shouldn't be a problem.)
To use it, save the above script as playlist_to_xml.py, then use
Terminal or 'do shell script' to run a command like: