Created
January 27, 2010 08:27
-
-
Save imajes/287651 to your computer and use it in GitHub Desktop.
This file contains 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
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