Skip to content

Instantly share code, notes, and snippets.

@imajes
Created January 27, 2010 08:27
Show Gist options
  • Save imajes/287651 to your computer and use it in GitHub Desktop.
Save imajes/287651 to your computer and use it in GitHub Desktop.
file = ARGV.shift || "~/Music/iTunes/iTunes Music Library.xml"
albums = []
d = {}
IO.foreach(File.expand_path(file)) do |line|
if line =~ /<dict/
d.clear
elsif line =~ /<key>(Artist|Album)<\/key><.*?>(.*)<\/.*?>/
key = $1.downcase.first.intern
d[key] = $2
elsif line =~ /<\/dict>/ && d.size == 2
albums << "#{d[:artist]} - #{d[:album]}"
end
end
puts albums.uniq.sort
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment