WavPack and Musepack support

This commit is contained in:
Adrian Sampson 2011-01-03 15:32:58 -08:00
parent 8f5ce886ab
commit 580e4acf10
5 changed files with 29 additions and 3 deletions

5
NEWS
View file

@ -3,6 +3,11 @@
* A new "-q" command line switch for the import command suppresses all
prompts for input; it pessimistically skips all albums that the
importer is not completely confident about.
* Added support for the WavPack and Musepack formats. Unfortunately,
due to a limitation in the Mutagen library (used by beets for
metadata manipulation), Musepack SV8 is not yet supported. Here's
the upstream bug in question:
http://code.google.com/p/mutagen/issues/detail?id=7
* BPD now uses a pure-Python socket library and no longer requires
eventlet/greenlet (the latter of which is a C extension). For the
curious, the socket library in question is called Bluelet:

View file

@ -59,6 +59,8 @@ TYPES = {
'ogg': 'OGG',
'flac': 'FLAC',
'ape': 'APE',
'wv': 'WavPack',
'mpc': 'Musepack',
}
@ -244,8 +246,8 @@ class MediaField(object):
def __init__(self, out_type = unicode, **kwargs):
"""Creates a new MediaField.
- out_type: The field's semantic (exterior) type.
- kwargs: A hash whose keys are 'mp3', 'mp4', 'flac', 'ogg',
and 'ape' and whose values are StorageStyle instances
- kwargs: A hash whose keys are 'mp3', 'mp4', and 'etc'
and whose values are StorageStyle instances
parameterizing the field's storage for each type.
"""
self.out_type = out_type
@ -503,6 +505,10 @@ class MediaFile(object):
self.type = 'ogg'
elif type(self.mgfile).__name__ == 'MonkeysAudio':
self.type = 'ape'
elif type(self.mgfile).__name__ == 'WavPack':
self.type = 'wv'
elif type(self.mgfile).__name__ == 'Musepack':
self.type = 'mpc'
else:
raise FileTypeError('file type %s unsupported by MediaFile' %
type(self.mgfile).__name__)
@ -685,6 +691,9 @@ class MediaFile(object):
#fixme: The utility of this guess is questionable.
return self.mgfile.info.sample_rate * \
self.mgfile.info.bits_per_sample
elif self.type == 'wv':
# Mutagen doesn't provide enough information.
return 0
else:
return self.mgfile.info.bitrate

BIN
test/rsrc/full.mpc Normal file

Binary file not shown.

BIN
test/rsrc/full.wv Normal file

Binary file not shown.

View file

@ -203,7 +203,6 @@ correct_dicts = {
}
read_only_correct_dicts = {
'full.mp3': {
'length': 1.0,
'bitrate': 80000,
@ -234,6 +233,17 @@ read_only_correct_dicts = {
'format': 'APE',
},
'full.wv': {
'length': 1.0,
'bitrate': 0,
'format': 'WavPack',
},
'full.mpc': {
'length': 1.0,
'bitrate': 23,
'format': 'Musepack',
},
}
def suite_for_file(path, correct_dict, writing=True):
@ -253,6 +263,8 @@ test_files = {
'flac': ['full', 'partial', 'min'],
'ogg': ['full'],
'ape': ['full'],
'wv': ['full'],
'mpc': ['full'],
}
def suite():