I like the bit that appears at the bottom of iTunes, telling you how much music you have in your collection (or in the current playlist).

I thought it might be fun to see how much music I had listened to. As it turns out:
5883 songs, 17:13:27:05 total time.
Here is the script I wrote to find it out.
#! /usr/bin/env python import Foundation import os library = os.path.expanduser('~/Music/iTunes/iTunes Music Library.xml') db = Foundation.NSDictionary.dictionaryWithContentsOfFile_(library) tracks = db[u'Tracks'].itervalues() timecount = 0 playcount = 0 for track in tracks: try: timecount = timecount + track[u'Play Count'] * track[u'Total Time']/1000 playcount = playcount + track[u'Play Count'] except KeyError: pass days, timecount = timecount / (60 * 60 * 24), timecount % (60 * 60 * 24) hours, timecount = timecount / (60 * 60), timecount % (60 * 60) minutes, seconds = timecount / 60, timecount % 60 print '%i songs, %i:%02i:%02i:%02i total time' % (playcount, days, hours, minutes, seconds)
I am not able to get this to work. When I run this script, it can not find the Foundation module. Where is this installed?
2 days, 19 hours after the fact.
Sorry, you need to have PyPbjC installed.
2 days, 21 hours after the fact.