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://
file://
"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.
>>> test = iTunesLibrary(
>>> found = test.Search(
>>> len(found)
46
>>> five_stars = PLSFormat(found, name = "Five Stars", extended = True, relocate_from = "file:/
>>> print five_stars
[playlist]
X-GNOME-Title=Five Stars
NumberOfEntries=46
File1=file:
Title1=Lothlorien - Schottische Fran Havero
Length1=332
File2=file:
Title2=Talking Heads - Once in a Lifetime
Length2=325
File3=file:
Title3=Jethro Tull - Teacher
Length3=233
[...]
See the unittests (ituneslib/
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
-
mopidy-podcast-itunes source package in Bionic
Version 2.0.0-2 uploaded on 2016-08-15 -
mopidy-podcast-itunes source package in Artful
Version 2.0.0-2 uploaded on 2016-08-15 -
amarok source package in Sid
Version 2.8.0-8 uploaded on 2017-01-16
