Use Mutagen MP4 codec reporting

Not released yet. See:
2c03ac7019
This commit is contained in:
Adrian Sampson 2014-11-11 10:16:15 -08:00
parent d3f0742276
commit 0c164a93e0

View file

@ -1340,15 +1340,20 @@ class MediaFile(object):
raise FileTypeError(path)
elif (type(self.mgfile).__name__ == 'M4A' or
type(self.mgfile).__name__ == 'MP4'):
# This hack differentiates AAC and ALAC until we find a more
# deterministic approach. Mutagen only sets the bitrate
# for AAC files. See:
# https://github.com/sampsyo/beets/pull/295
if hasattr(self.mgfile.info, 'bitrate') and \
self.mgfile.info.bitrate > 0:
self.type = 'aac'
if hasattr(self.mgfile.info, 'codec'):
if self.mgfile.codec and self.mgfile.codec.startswith('alac'):
self.type = 'alac'
else:
self.type = 'aac'
else:
self.type = 'alac'
# This hack differentiates AAC and ALAC on versions of
# Mutagen < 1.26. Once Mutagen > 1.26 is out and
# required by beets, we can remove this.
if hasattr(self.mgfile.info, 'bitrate') and \
self.mgfile.info.bitrate > 0:
self.type = 'aac'
else:
self.type = 'alac'
elif (type(self.mgfile).__name__ == 'ID3' or
type(self.mgfile).__name__ == 'MP3'):
self.type = 'mp3'