I used this:
http://ruby-mp3info.rubyforge.org/
or
gem install ruby-mp3info (add sudo rule for Mac or * nix)
There is some rdoc documentation, which is nice. On the other hand, I don't really like the use of uppercase field names, which seem to be too worried about keeping names from the specification. Maybe I should hack some aliases. Anyway, this sample script scans my music library and counts the words in the headers:
require 'mp3info' count = 0 words = Hash.new { |h, k| h[k] = 0 } Dir.glob("E:/MUSIC/**/*.mp3") do |f| count += 1 Mp3Info.open(f) do |mp3info| title = mp3info.tag2.TIT2 next unless title title.split(/\s/).each { |w| words[w.downcase] += 1 } end end puts "Examined #{count} files" words.to_a.sort{ |a, b| b[1] <=> a[1] }[0,100].each { |w| puts "#{w[0]}: #{w[1]}" }
Mike woodhouse
source share