I’m pretty new to Ruby [this is my second script], but I’m trying to
write a little playlist generator script to scan a few directories every
once in a while [probably in a cron job], and update a .m3u playlist
based on what it finds. I like having info in my playlist so it loads
automatically with the playlist, so I’m trying to use the Mp3Info
module. I’ve got my list of files in an array called files. Here’s the
code I’m using to test things out:
i = 0
files.each do |f|
Mp3Info.open(f) do |info|
i += 1
i is just to see how far it’s getting, and puts f is just to see what
the particular song is.
It runs just fine, up to i=32. At that point, it errors out, with:
read': failed to allocate memory (NoMemoryError) from /usr/lib64/ruby/gems/1.8/gems/ruby-mp3info-0.5/lib/mp3info/id3v2.rb:280:inadd_value_to_tag2’
read_id3v2_3_frames' from /usr/lib64/ruby/gems/1.8/gems/ruby-mp3info-0.5/lib/mp3info/id3v2.rb:220:inread_id3v2_3_frames’
from_io' from /usr/lib64/ruby/gems/1.8/gems/ruby-mp3info-0.5/lib/mp3info.rb:420:inparse_tags’
initialize' from /usr/lib64/ruby/gems/1.8/gems/ruby-mp3info-0.5/lib/mp3info.rb:279:inopen’
Am I doing things wrong? Or is it just running out of memory? If it’s
the latter, is there any way to expand the amount of memory for
Ruby/Mp3Info to use?
All I really want to do is get the song length, artist and title…is
there any better way to do it?
PS. I’m using Ruby 1.8.3 and Mp3Info 0.5 on AMD64 with the patch at