Skip to content

Instantly share code, notes, and snippets.

@jaspertandy
Created December 14, 2012 11:06
Show Gist options
  • Save jaspertandy/4284676 to your computer and use it in GitHub Desktop.
Save jaspertandy/4284676 to your computer and use it in GitHub Desktop.
#!/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