Catch eyeD3.tag.GenreException from mp3 files with bad genre

Bug #633218 reported by Peter on 2010-09-08
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Entertainer Media Center
Undecided
Unassigned

Bug Description

I'm testing entertainer 0.5.1 compiled from source on Ubuntu Lucid.

One of my mp3 files had the following as the ID3 genre field: CLASSICAL(VOCAL,EARLY,CHAMBER)

The eyeD3 library does not like this (I guess due to the brackets) and as it fails it regular expression test throws eyeD3.tag.GenreException. This then aborts metadata extraction for this file, as shown in logging printed at the terminal:

2010-09-08 15:29:41+0100 [-] Exception in thread IndexerThread:
2010-09-08 15:29:41+0100 [-] Traceback (most recent call last):
2010-09-08 15:29:41+0100 [-] File "/usr/lib/python2.6/threading.py", line 532, in __bootstrap_inner
2010-09-08 15:29:41+0100 [-] self.run()
2010-09-08 15:29:41+0100 [-] File "/home/peterjc/Downloads/entertainer-0.5.1/entertainerlib/backend/components/mediacache/indexer_thread.py", line 65, in run
2010-09-08 15:29:41+0100 [-] cache.addDirectory(element)
2010-09-08 15:29:41+0100 [-] File "/home/peterjc/Downloads/entertainer-0.5.1/entertainerlib/backend/components/mediacache/music_cache.py", line 126, in addDirectory
2010-09-08 15:29:41+0100 [-] self.addFile(os.path.join(root, name))
2010-09-08 15:29:41+0100 [-] File "/home/peterjc/Downloads/entertainer-0.5.1/entertainerlib/backend/components/mediacache/music_cache.py", line 66, in addFile
2010-09-08 15:29:41+0100 [-] self.__addMP3file(filename)
2010-09-08 15:29:41+0100 [-] File "/home/peterjc/Downloads/entertainer-0.5.1/entertainerlib/backend/components/mediacache/music_cache.py", line 283, in __addMP3file
2010-09-08 15:29:41+0100 [-] genre = str(tags.getGenre())
2010-09-08 15:29:41+0100 [-] File "/usr/lib/pymodules/python2.6/eyeD3/tag.py", line 648, in getGenre
2010-09-08 15:29:41+0100 [-] g.parse(f[0].text);
2010-09-08 15:29:41+0100 [-] File "/usr/lib/pymodules/python2.6/eyeD3/tag.py", line 1551, in parse
2010-09-08 15:29:41+0100 [-] (regex.pattern, genreStr));
2010-09-08 15:29:41+0100 [-] GenreException: Genre string cannot be parsed with '^[A-Z 0-9+/\-\|!&'\.]+*$': CLASSICAL(VOCAL,EARLY,CHAMBER)
2010-09-08 15:29:41+0100 [-]

My suggested fix is to replace this in file entertainerlib/backend/components/mediacache/music_cache.py, class MusicCache, method __addMP3file:

        # Get track genre
        genre = str(tags.getGenre())
        if genre is None or len(genre) == 0:
            genre = self.__DEFAULT['genre']

with this new code:

        # Get track genre
        try:
            genre = str(tags.getGenre())
        except eyeD3.tag.GenreException:
            #raised on some ID3 genre strings, e.g. containing brackets
            genre = None
        if genre is None or len(genre) == 0:
            genre = self.__DEFAULT['genre']

This means the genre for such problem files is ignored, but the rest of the data is parsed and the file should then appear in the library.

Perhaps a bug should be filed in eyeD3 as well?

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers