Created
May 20, 2011 15:22
-
-
Save leejarvis/983143 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
#!/usr/bin/env ruby | |
require 'nokogiri' | |
path = ARGV.shift || File.join(ENV['HOME'], "Music/iTunes/iTunes Music Library.xml") | |
doc = Nokogiri.XML File.open(path) | |
tracks = [] | |
doc.xpath('/plist/dict/dict/dict').each do |node| | |
children = node.children.map(&:text).reject { |x| x.strip.empty? } | |
tracks << Hash[children.each_cons(2).to_a] | |
end | |
p tracks.first['Name'] #=> some awesome track name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment