Reputation: 2869
Currently I'm working on a music project, dealing with user mp3 uploads. The problem is that I can't find an id3 library that will work correctly for all files.
I have tried id3-ruby
and Mp3Info
libs but none of them gives me consistently correct results.
For example, most common problems:
I decided to add a form, where users can supply optional information like Artist and title; that helped a little, but didn't completely solve the problem.
What's the most usable and powerful ID3 library for ruby?
Upvotes: 9
Views: 7871
Reputation: 843
As of 2019, the best answers are:
All other libraries are long-since unmaintained.
Upvotes: 1
Reputation: 9938
id3tag
is another option. Example:
require "id3tag"
mp3_file = File.open('/path/to/your/favorite_song.mp3', "rb")
tag = ID3Tag.read(mp3_file)
puts "#{tag.artist} - #{tag.title}"
Upvotes: 0
Reputation: 52316
I've used this:
http://ruby-mp3info.rubyforge.org/
or
gem install ruby-mp3info
(add the regulation sudo
for Mac or *nix)
There's some rdoc documentation, which is nice. On the downside, I don't much like the use of upper-case field names, which seems too concerned to preserve the names from the spec. Maybe I should hack in some aliases. Anyway, this sample script scans my music library and counts words in titles:
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]}" }
Upvotes: 4
Reputation: 8070
http://id3lib-ruby.rubyforge.org/
I particularly liked this one, you can also write tags to the file.
Upvotes: 0
Reputation: 74654
http://www.hakubi.us/ruby-taglib/
I used this for a project and it worked quite well. Wrapper around taglib, which is very portable.
Upvotes: 6