Registered 2007-01-27 by Eamonn Sullivan

A simple python module for extracting playlists, ratings and other information from iTunes and exporting the data into a number of portable formats (well, two to start with). I used it while moving from iTunes to Rhythmbox in Gnome and Amarok on KDE.

The iTunes Export Library is a simple python module for extracting playlists, ratings and other information from iTunes and exporting it into a number of portable formats. I used it while moving from iTunes to Rhythmbox in Gnome and Amarok on KDE.

The only requirement is python 2.3 or later and an iTunes library
file, usually saved as "iTunes Music Library.xml" in your iTunes
directory on Windows and the Mac.

The itunes2pl.py file is a command-line program that uses a subset of the module features and is a good way to learn out it works. The simplest way to use it is:

python itunes2pl.py "iTunes Music Library.xml" "My Top Rated"

That will extract your top rated songs and output it (to standard out) in PLS format. Redirect the output to a file (using .pls as an
extension). You may have to open the file in your favorite
editor and edit the pathnames if you've moved your music from the Mac or Windows to, say, Linux.

There are many options for controlling itunes2pl. For example, you can save the information in m3u format, or use extended m3u format. You can also output the information into extended (version 2) pls format. Another useful option is to rewrite the paths to the music files to match their new location. Type:

python itunes2pl.py --help

for a complete list of the options.

Here's an example of advanced usage. I moved my iTunes music directory from my iMac to my PC, which is running Ubuntu. Once I moved the files over and copied the "iTunes Music Library.xml" to Ubuntu, I ran itunes2pl.py like this to extract my "quiet" playlist and save them to a playlist file that I can import into Rhythmbox (all of this is on one line):

python itunes2pl.py -f pls -e --name "quiet" -r
file://localhost/Users/esullivan/Music/iTunes/iTunes%20Music/
file:///home/esullivan/Music/ "test_data/iTunes Music Library.xml"
"quiet" >quiet.pls

I used the -f (or --format) option to specify pls format, -e (or
--extended) option to specify the more extensive version 2 of the pls format. I could have also used the m3u (winamp) format and the extended version of that file format. I also used the -r (or --relocate) option, which takes two strings: the first is the part of the location of each file that I want to change and the second is what I want to replace it with. I then specify the location of my iTunes music library file and the name of the playlist I want to export. Finally, I redirect the output to a file.

One feature the command-line program doesn't use is the Search method. Here's how I used it in the python interpreter to export all of my songs that are rated with five stars (the iTunes format uses 100 for five starts, 80 for four, 60 for three, 40 for two, 20 for one.)

>>> from ituneslib import iTunesLibrary
>>> from ituneslib.output_formats import PLSFormat, M3UFormat
>>> test = iTunesLibrary("test_data/large.xml")
>>> found = test.Search({'Rating' : 100})
>>> len(found)
46
>>> five_stars = PLSFormat(found, name = "Five Stars", extended = True, relocate_from = "file://localhost/Users/esullivan/Music/iTunes/iTunes%20Music/", relocate_to = "file:///home/esullivan/Music/")
>>> print five_stars
[playlist]
X-GNOME-Title=Five Stars
NumberOfEntries=46
File1=file:///home/esullivan/Music/Lothlorien/Greenwood%20Side/Schottische%20Fran%20Havero.mp3
Title1=Lothlorien - Schottische Fran Havero
Length1=332
File2=file:///home/esullivan/Music/Talking%20Heads/Stop%20Making%20Sense/12%20Once%20in%20a%20Lifetime.mp3
Title2=Talking Heads - Once in a Lifetime
Length2=325
File3=file:///home/esullivan/Music/Jethro%20Tull/The%20Best%20of%20Jethro%20Tull/01%20Teacher.mp3
Title3=Jethro Tull - Teacher
Length3=233
[...]

See the unittests (ituneslib/core_test.py and ituneslib/output_formats_test.py) for more examples.

Project information

Maintainer:
Eamonn Sullivan
Driver:
Not yet selected
Licence:
I don't know yet

RDF metadata

View full history Series and milestones

trunk series is the current focus of development.

All code Code

Version control system:
Bazaar
Programming languages:
python

All packages Packages in Distributions

Get Involved

  • warning
    Report a bug
  • warning
    Ask a question
  • warning
    Help translate

Downloads

iTunes Export does not have any download files registered with Launchpad.