Issue #39 resolved

Handle mp3s that do not report mp3 mime-type.

Travis Shirk
repo owner created an issue

Since using python-magic digs deeper into what mime-type a file is there are some (many) in my collect that are not detected as such. These types are mp3 (loading, parsing them succeeds) but are not deemed the right mime-type by python-magic:

$ eyeD3 -P mp3-wrong-mt /home/travis/music
...
Types: set(['application/octet-stream', 'audio/x-hx-aac-adts', 'audio/x-wav'])

The x-wav types are mp3s wrapped in a RIFF container: http://www.studiodust.com/riffmp3.html

Not sure about the application/octet-stream and audio/x-hx-aac-adts, but the contents parse/play mp3.

These edge cases need to be handled and loaded/parsed by eyeD3.

Comments (2)

  1. Travis Shirk reporter

    This plugin is helpful for detecting these files:

    class WeirdMimeTypes(Plugin):
        NAMES = ["mp3-wrong-mt"]
        SUMMARY = u"Find all files ending in .mp3 that do not have an mp3 mime-type"
    
        def __init__(self, arg_parser):
            super(WeirdMimeTypes, self).__init__(arg_parser)
            self.types = set()
    
        def handleFile(self, f):
            from eyed3.mp3 import MIME_TYPES
            from eyed3.utils import guessMimetype
    
            mt = guessMimetype(f)
            if f.endswith(".mp3") and mt not in MIME_TYPES:
                print("%s --> %s" % (mt, f))
                self.types.add(mt)
    
        def handleDone(self):
            from pprint import pformat
            print("Types: %s" % pformat(self.types))
    
  2. Log in to comment