本文整理汇总了Python中mutagen.flac.MetadataBlock.code方法的典型用法代码示例。如果您正苦于以下问题:Python MetadataBlock.code方法的具体用法?Python MetadataBlock.code怎么用?Python MetadataBlock.code使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mutagen.flac.MetadataBlock
的用法示例。
在下文中一共展示了MetadataBlock.code方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __read_metadata_block
# 需要导入模块: from mutagen.flac import MetadataBlock [as 别名]
# 或者: from mutagen.flac.MetadataBlock import code [as 别名]
def __read_metadata_block(self, file):
byte = ord(file.read(1))
size = to_int_be(file.read(3))
try:
data = file.read(size)
if len(data) != size:
raise Exception("file said %d bytes, read %d bytes" % (size, len(data)))
block = self.METADATA_BLOCKS[byte & 0x7F](data)
except (IndexError, TypeError):
block = MetadataBlock(data)
block.code = byte & 0x7F
self.metadata_blocks.append(block)
else:
self.metadata_blocks.append(block)
if block.code == VCFLACDict.code:
if self.tags is None:
self.tags = block
else:
raise FLACVorbisError("> 1 Vorbis comment block found")
elif block.code == CueSheet.code:
if self.cuesheet is None:
self.cuesheet = block
else:
raise Exception("> 1 CueSheet block found")
elif block.code == SeekTable.code:
if self.seektable is None:
self.seektable = block
else:
raise Exception("> 1 SeekTable block found")
return (byte >> 7) ^ 1
示例2: test_save_unknown_block
# 需要导入模块: from mutagen.flac import MetadataBlock [as 别名]
# 或者: from mutagen.flac.MetadataBlock import code [as 别名]
def test_save_unknown_block(self):
block = MetadataBlock("test block data")
block.code = 99
self.flac.metadata_blocks.append(block)
self.flac.save()