本文整理汇总了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()))
示例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()))
示例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)
示例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)
示例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)
示例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)
示例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
示例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)