Created
December 14, 2012 11:06
-
-
Save jaspertandy/4284676 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' | |
file = File.expand_path '~/../Dropbox/Public/2012.xml' | |
xml = Nokogiri::XML( File.new( file ) ); | |
albums = xml.xpath '//key[. = "Album"]' | |
all = [] | |
albums.each do |album| | |
artist = album.parent.at_xpath( './/key[. = "Artist"]' ) | |
all.push( { | |
artist: artist.next.content, | |
album: album.next.content | |
} ) | |
end | |
all = all.uniq { |x| x[:album] } | |
all.sort! { |x,y| x[:artist].downcase <=> y[:artist].downcase } | |
all.each { |album| puts "#{album[:artist]} - #{album[:album]}\r" } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment