Adam Twardoch's iTunes scripts

This page contains Adam Twardoch's scripts for iTunes written in Python.


exportimport_itunes_ratings_as_popm.py

Version 1.0
Copyright (c) 2006 by Adam Twardoch. The script can be used free of charge without limitations. Changes should be reported to the author.

Download exportimport_itunes_ratings_as_popm.py

Python application that converts between track ratings stored in the iTunes library and those embedded inside of an MP3 file (as the 'POPM' popularimeter tag.) It also stores the played count field in the 'POPM' ID3 tag.

Example use:

itr = iTunesRatings()
# Export all iTunes library ratings into MP3 files:
itr.ExportRatingsForAlliTunesTracks()
# Import ratings from MP3 files into the iTunes library:
itr.ImportRatingsForAlliTunesTracks() 

Notes:

  1. While the POPM tag supports ratings from 0 to 255, the iTunes library supports ratings from 0 to 100. This script always uses the iTunes rating scale so the values 0-100 are stored in the POPM tag.
  2. The POPM tag requires an e-mail address that identifies the source of the rating. This script uses the fantasy address '[email protected]'.
  3. The application works on Windows and Mac OS X. On Windows, it uses COM automation through the win32all extensions. On Mac, it uses AppleScript through the appscript package. You need to download and install the appropriate package on your system.
  4. It also uses the mutagen package for reading and writing ID3 tags. Download and unpack the mutagen archive. On Windows, choose Start / Run and type in 'cmd'. Then use the 'cd' command to navigate to the folder where the unpacked the mutagen archive is and type 'python setup.py install'. On Mac, start Terminal, use the 'cd' command to navigate to the folder where you unpacked the mutagen archive and type 'sudo python setup.py install'.