Pergunta

I'm implementing a ruby on rails app that downloads songs from a dropbox folder and then performs a couple of actions on them such as extracting a few metatags. Right now, I'm using 10 mp3s that belong to the same album, so they have the same encoding etc. However, when trying to read the metatags using taglib-ruby 3 of the 10 files throw an error, saying:

TagLib: FileRef::tag() - Called without a valid file.
TagLib: FileRef::audioProperties() - Called without a valid file.

I used the code provided here on the left as a guide, leading to:

  def read_metatags
    TagLib::FileRef.open(self.local_path) do |fileref|
      unless fileref.null?
        logger.info "Reading tags"
        tag = fileref.tag
        self.title = tag.title
        self.artist = tag.artist

        properties = fileref.audio_properties
        self.length = properties.length
      end
    end
    self.save!
  end

First I thought that the downloaded file may be corrupted, but checking the metadata in nautilus shows ok results and rhythmbox can play it as well. I want to use taglib-ruby's Basic API instead of the format specific one as I only need to retrieve the artist and title but need to be able to get it from files of various formats.

Does anyone have any ideas how to fix this? It might be I'm missing something super obvious, given that I'm a newbie regarding the topic.

edit: Considering robinst's comment, this is the ls -l listing of the respective files:

-rw-rw-r-- 1 user user 3710598 Jun  3 15:56 01 - Paradise.mp3
-rw-rw-r-- 1 user user 3731496 Jun  3 15:56 02 - Weirdo.mp3
-rw-rw-r-- 1 user user 3620319 Jun  3 15:56 03 - As It Is When It Was.mp3
-rw-rw-r-- 1 user user 3645815 Jun  3 15:56 04 - Broken Promise.mp3
-rw-rw-r-- 1 user user 3954295 Jun  3 15:56 05 - Way Of Life.mp3
-rw-rw-r-- 1 user user 4199193 Jun  3 15:57 06 - Bizarre Love Triangle.mp3
-rw-rw-r-- 1 user user 5002092 Jun  3 15:57 07 - All Day Long.mp3
-rw-rw-r-- 1 user user 3595686 Jun  3 15:57 08 - Angel Dust.mp3
-rw-rw-r-- 1 user user 4307888 Jun  3 15:57 09 - Every Little Counts.mp3
-rw-rw-r-- 1 user user 6313648 Jun  3 15:57 10 - State Of The Nation.mp3
Foi útil?

Solução

This question was also asked as issue 33 in taglib-ruby and answered there. In short, the files turned out to be broken.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top