def get_metadata(self): """returns a MetaData object, or None raises IOError if unable to read the file""" from audiotools.bitstream import BitstreamReader from audiotools.id3 import ID3v22Comment for chunk in self.chunks(): if (chunk.id == 'ID3 '): return ID3v22Comment.parse(BitstreamReader(chunk.data(), 0)) else: return None