iTunes top 10 ... how to deal with boredom
#!/usr/bin/env ruby
LIBRARY_PATH = File.expand_path("~/Music/iTunes/iTunes Music Library.xml")
require 'rubygems'
require_gem 'plist'
class Plist
class PDate < PTag
def to_ruby
text
end
end
class PData < PTag
def to_ruby
text
end
end
end
d = Plist::parse_xml(LIBRARY_PATH)
top10=d['Tracks'].values.sort{|a,b| (a['Play Count'] ||= 0) <=> (b['Play Count'] ||= 0)}.reverse[0..10]
top10.each do |t|
puts "#{t['Name']} by #{t['Artist']}"
end
Just to be on the safe side, better first backup your "iTunes Music Library.xml" or operate on a backup to begin with
As always: Use this at your own risk.
