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


Python OggPage.packets[0]方法代码示例

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


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

示例1: test_unsupported_version

# 需要导入模块: from mutagen.ogg import OggPage [as 别名]
# 或者: from mutagen.ogg.OggPage import packets[0] [as 别名]
    def test_unsupported_version(self):
        page = OggPage(open(self.filename, "rb"))
        data = bytearray(page.packets[0])

        data[8] = 0x03
        page.packets[0] = bytes(data)
        OggOpusInfo(BytesIO(page.write()))

        data[8] = 0x10
        page.packets[0] = bytes(data)
        self.failUnlessRaises(IOError, OggOpusInfo, BytesIO(page.write()))
开发者ID:svetlio2,项目名称:hackbg,代码行数:13,代码来源:test_oggopus.py

示例2: test_unsupported_version

# 需要导入模块: from mutagen.ogg import OggPage [as 别名]
# 或者: from mutagen.ogg.OggPage import packets[0] [as 别名]
    def test_unsupported_version(self):
        page = OggPage(open(self.filename, "rb"))
        data = list(page.packets[0])

        data[8] = "\x03"
        page.packets[0] = "".join(data)
        OggOpusInfo(StringIO(page.write()))

        data[8] = "\x10"
        page.packets[0] = "".join(data)
        self.failUnlessRaises(IOError, OggOpusInfo, StringIO(page.write()))
开发者ID:andrewboie,项目名称:discogstool,代码行数:13,代码来源:test_oggopus.py

示例3: test_negative_bitrate

# 需要导入模块: from mutagen.ogg import OggPage [as 别名]
# 或者: from mutagen.ogg.OggPage import packets[0] [as 别名]
 def test_negative_bitrate(self):
     page = OggPage(open(self.filename, "rb"))
     packet = page.packets[0]
     packet = (packet[:16] + b"\xff\xff\xff\xff" + b"\xff\xff\xff\xff" +
               b"\xff\xff\xff\xff" + packet[28:])
     page.packets[0] = packet
     info = OggVorbisInfo(cBytesIO(page.write()))
     self.failUnlessEqual(info.bitrate, 0)
开发者ID:akerbis,项目名称:mutagen,代码行数:10,代码来源:test_oggvorbis.py

示例4: test_underestimated_bitrate

# 需要导入模块: from mutagen.ogg import OggPage [as 别名]
# 或者: from mutagen.ogg.OggPage import packets[0] [as 别名]
 def test_underestimated_bitrate(self):
     page = OggPage(open(self.filename, "rb"))
     packet = page.packets[0]
     packet = (packet[:16] + b"\x00\x00\x01\x00" + b"\x01\x00\x00\x00" +
               b"\x00\x00\x01\x00" + packet[28:])
     page.packets[0] = packet
     info = OggVorbisInfo(cBytesIO(page.write()))
     self.failUnlessEqual(info.bitrate, 65536)
开发者ID:akerbis,项目名称:mutagen,代码行数:10,代码来源:test_oggvorbis.py

示例5: test_overestimated_bitrate

# 需要导入模块: from mutagen.ogg import OggPage [as 别名]
# 或者: from mutagen.ogg.OggPage import packets[0] [as 别名]
 def test_overestimated_bitrate(self):
     page = OggPage(file(self.filename, "rb"))
     packet = page.packets[0]
     packet = (packet[:16] + "\x00\x00\x01\x00" + "\x00\x00\x00\x01" +
               "\x00\x00\x00\x00" + packet[28:])
     page.packets[0] = packet
     info = OggVorbisInfo(StringIO(page.write()))
     self.failUnlessEqual(info.bitrate, 65536)
开发者ID:Knio,项目名称:tag2itunes,代码行数:10,代码来源:test_oggvorbis.py

示例6: test_avg_bitrate

# 需要导入模块: from mutagen.ogg import OggPage [as 别名]
# 或者: from mutagen.ogg.OggPage import packets[0] [as 别名]
 def test_avg_bitrate(self):
     page = OggPage(open(self.filename, "rb"))
     packet = page.packets[0]
     packet = (packet[:16] + "\x00\x00\x01\x00" + "\x00\x00\x00\x00" +
               "\x00\x00\x00\x00" + packet[28:])
     page.packets[0] = packet
     info = OggVorbisInfo(StringIO(page.write()))
     self.failUnlessEqual(info.bitrate, 32768)
开发者ID:Jbonnett,项目名称:Mutagen-flo,代码行数:10,代码来源:test_oggvorbis.py

示例7: yield_pages

# 需要导入模块: from mutagen.ogg import OggPage [as 别名]
# 或者: from mutagen.ogg.OggPage import packets[0] [as 别名]
def yield_pages(track_derived):
    fh = track_derived.open()
    yield OggPage(fh)
    tmp = OggPage(fh)
    # replace outgoing tag
    tmp.packets[0] = create_metadata_packet([
        ('title', track_derived.original.title),
        ('artist', track_derived.original.artist),
        ('x-ireul-id', unicode(track_derived.id))])
    yield tmp
    try:
        while True:
            yield OggPage(fh)
    except EOFError:
        pass
开发者ID:XiaonuoGantan,项目名称:ireul,代码行数:17,代码来源:icy_write_vorb.py

示例8: yield_events

# 需要导入模块: from mutagen.ogg import OggPage [as 别名]
# 或者: from mutagen.ogg.OggPage import packets[0] [as 别名]
def yield_events(track_derived):
    fh = track_derived.open()
    yield TrackStartedEvent(track_derived)
    yield OggPageEvent(OggPage(fh))
    tmp = OggPage(fh)
    # replace outgoing tag
    metadata = []
    metadata.append(('title', track_derived.original.title))
    metadata.append(('artist', track_derived.original.artist))
    if hasattr(track_derived.original.metadata, 'album_name'):
        metadata.append(('album', track_derived.original.metadata.album_name))
    if hasattr(track_derived.original.metadata, 'year'):
        metadata.append(('year', track_derived.original.metadata.year))
    metadata.append(('x-ireul-id', unicode(track_derived.original.id)))
    tmp.packets[0] = create_metadata_packet(metadata)
    yield OggPageEvent(tmp)
    try:
        while True:
            yield OggPageEvent(OggPage(fh))
    except EOFError:
        pass
    yield TrackEndedEvent(track_derived)
开发者ID:infinityb,项目名称:ireul-dead,代码行数:24,代码来源:icy_write_vorb.py


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