1. Felix Krull
  2. rgain
  3. Issues
Issue #10 resolved

tags.get for an empty file: AttributeError: 'NoneType' object has no attribute 'get'

Dennis Schridde
created an issue

It appears that rgain does not handle empty files very well:

$ collectiongain <PATH>

(gst-plugin-scanner:9931): GStreamer-CRITICAL **: gst_structure_new_empty: assertion `gst_structure_validate_name (name)' failed
Collecting files ...
  [1] <FILENAME>.ogg |
Traceback (most recent call last):
  File "/usr/bin/collectiongain-2.7", line 7, in <module>
  File "/usr/lib64/python2.7/site-packages/rgain/script/collectiongain.py", line 392, in collectiongain
    opts.mp3_format, opts.ignore_cache, opts.jobs)
  File "/usr/lib64/python2.7/site-packages/rgain/script/collectiongain.py", line 328, in do_collectiongain
  File "/usr/lib64/python2.7/site-packages/rgain/script/collectiongain.py", line 181, in collect_files
    album_id = get_album_id(music_dir, filepath)
  File "/usr/lib64/python2.7/site-packages/rgain/script/collectiongain.py", line 119, in get_album_id
    album_id = tags.get("musicbrainz_albumid")[0]
AttributeError: 'NoneType' object has no attribute 'get'

While you are at it: Corrupted MP3 files produce a similar issue:

Traceback (most recent call last):
  File "/usr/lib64/python2.7/site-packages/rgain/script/collectiongain.py", line 105, in get_album_id
    tags = mutagen.File(properpath)
  File "/usr/lib64/python2.7/site-packages/mutagen/__init__.py", line 215, in File
    if score > 0: return Kind(filename)
  File "/usr/lib64/python2.7/site-packages/mutagen/__init__.py", line 73, in __init__
    self.load(filename, *args, **kwargs)
  File "/usr/lib64/python2.7/site-packages/mutagen/id3.py", line 2096, in load
    self.info = self._Info(fileobj, offset)
  File "/usr/lib64/python2.7/site-packages/mutagen/mp3.py", line 103, in __init__
    self.__try(fileobj, offset, size - offset, False)
  File "/usr/lib64/python2.7/site-packages/mutagen/mp3.py", line 140, in __try
    raise HeaderNotFoundError("can't sync to an MPEG frame")
HeaderNotFoundError: can't sync to an MPEG frame

Comments (1)

  1. Log in to comment