Created
February 8, 2012 20:03
-
-
Save pmallory/1772885 to your computer and use it in GitHub Desktop.
Music Histogram
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from Foundation import * | |
from ScriptingBridge import * | |
iTunes = SBApplication.applicationWithBundleIdentifier_( | |
"com.apple.iTunes") | |
years = {} | |
for track in iTunes.currentPlaylist().tracks(): | |
if not track.year() in years: | |
years[track.year()] = 1 | |
else: | |
years[track.year()] += 1 | |
f = open('./out.csv', 'w') | |
for key in sorted(years.keys()): | |
f.write(str(key)+', '+str(years[key]) +'\n') | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment