当前位置: 首页>>代码示例>>Python>>正文


Python MetadataBlock.writeblocks方法代码示例

本文整理汇总了Python中mutagen.flac.MetadataBlock.writeblocks方法的典型用法代码示例。如果您正苦于以下问题:Python MetadataBlock.writeblocks方法的具体用法?Python MetadataBlock.writeblocks怎么用?Python MetadataBlock.writeblocks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mutagen.flac.MetadataBlock的用法示例。


在下文中一共展示了MetadataBlock.writeblocks方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_header

# 需要导入模块: from mutagen.flac import MetadataBlock [as 别名]
# 或者: from mutagen.flac.MetadataBlock import writeblocks [as 别名]
    def get_header(self, filename=None):

        f = self.fileobj
        f.seek(0)

        # Ensure we've got padding at the end, and only at the end.
        # If adding makes it too large, we'll scale it down later.
        self.metadata_blocks.append(Padding("\x00" * 1020))
        MetadataBlock.group_padding(self.metadata_blocks)

        header = self.__check_header(f)
        # "fLaC" and maybe ID3
        available = self.__find_audio_offset(f) - header
        data = MetadataBlock.writeblocks(self.metadata_blocks)

        if len(data) > available:
            # If we have too much data, see if we can reduce padding.
            padding = self.metadata_blocks[-1]
            newlength = padding.length - (len(data) - available)
            if newlength > 0:
                padding.length = newlength
                data = MetadataBlock.writeblocks(self.metadata_blocks)
                assert len(data) == available

        elif len(data) < available:
            # If we have too little data, increase padding.
            self.metadata_blocks[-1].length += available - len(data)
            data = MetadataBlock.writeblocks(self.metadata_blocks)
            assert len(data) == available

        self.__offset = len("fLaC" + data)

        return "fLaC" + data
开发者ID:jbaiter,项目名称:beetfs,代码行数:35,代码来源:beetFs.py

示例2: test_group_padding

# 需要导入模块: from mutagen.flac import MetadataBlock [as 别名]
# 或者: from mutagen.flac.MetadataBlock import writeblocks [as 别名]
 def test_group_padding(self):
     blocks = [Padding("\x00" * 20), Padding("\x00" * 30),
               MetadataBlock("foobar")]
     blocks[-1].code = 0
     length1 = len(MetadataBlock.writeblocks(blocks))
     MetadataBlock.group_padding(blocks)
     length2 = len(MetadataBlock.writeblocks(blocks))
     self.failUnlessEqual(length1, length2)
     self.failUnlessEqual(len(blocks), 2)
开发者ID:andrewboie,项目名称:discogstool,代码行数:11,代码来源:test_flac.py

示例3: test_writeblocks

# 需要导入模块: from mutagen.flac import MetadataBlock [as 别名]
# 或者: from mutagen.flac.MetadataBlock import writeblocks [as 别名]
 def test_writeblocks(self):
     blocks = [Padding("\x00" * 20), Padding("\x00" * 30)]
     self.failUnlessEqual(len(MetadataBlock.writeblocks(blocks)), 58)
开发者ID:andrewboie,项目名称:discogstool,代码行数:5,代码来源:test_flac.py


注:本文中的mutagen.flac.MetadataBlock.writeblocks方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。