本文整理汇总了Python中mutagen.ogg.OggPage.find_last方法的典型用法代码示例。如果您正苦于以下问题:Python OggPage.find_last方法的具体用法?Python OggPage.find_last怎么用?Python OggPage.find_last使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mutagen.ogg.OggPage
的用法示例。
在下文中一共展示了OggPage.find_last方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_find_last_none_finishing_mux
# 需要导入模块: from mutagen.ogg import OggPage [as 别名]
# 或者: from mutagen.ogg.OggPage import find_last [as 别名]
def test_find_last_none_finishing_mux(self):
page1 = OggPage()
page1.last = True
page1.position = -1
page2 = OggPage()
page2.serial = page1.serial + 1
pages = [page1, page2]
data = BytesIO(b"".join([page.write() for page in pages]))
assert OggPage.find_last(data, page1.serial, finishing=True) is None
assert OggPage.find_last(data, page2.serial, finishing=True) == page2
示例2: test_find_last_last_empty
# 需要导入模块: from mutagen.ogg import OggPage [as 别名]
# 或者: from mutagen.ogg.OggPage import find_last [as 别名]
def test_find_last_last_empty(self):
# https://github.com/quodlibet/mutagen/issues/308
pages = [OggPage() for i in xrange(10)]
for i, page in enumerate(pages):
page.sequence = i
page.position = i
pages[-1].last = True
pages[-1].position = -1
data = BytesIO(b"".join([page.write() for page in pages]))
page = OggPage.find_last(data, pages[-1].serial, finishing=True)
assert page is not None
assert page.position == 8
page = OggPage.find_last(data, pages[-1].serial, finishing=False)
assert page is not None
assert page.position == -1
示例3: _post_tags
# 需要导入模块: from mutagen.ogg import OggPage [as 别名]
# 或者: from mutagen.ogg.OggPage import find_last [as 别名]
def _post_tags(self, fileobj):
"""Raises ogg.error"""
page = OggPage.find_last(fileobj, self.serial)
if page is None:
raise OggVorbisHeaderError
self.length = page.position / float(self.sample_rate)
示例4: test_find_last_really_last
# 需要导入模块: from mutagen.ogg import OggPage [as 别名]
# 或者: from mutagen.ogg.OggPage import find_last [as 别名]
def test_find_last_really_last(self):
pages = [OggPage() for i in range(10)]
pages[-1].last = True
for i, page in enumerate(pages): page.sequence = i
data = BytesIO(bytearray().join([page.write() for page in pages]))
self.failUnlessEqual(
OggPage.find_last(data, pages[0].serial), pages[-1])
示例5: test_find_last
# 需要导入模块: from mutagen.ogg import OggPage [as 别名]
# 或者: from mutagen.ogg.OggPage import find_last [as 别名]
def test_find_last(self):
pages = [OggPage() for i in xrange(10)]
for i, page in enumerate(pages):
page.sequence = i
data = BytesIO(b"".join([page.write() for page in pages]))
self.failUnlessEqual(
OggPage.find_last(data, pages[0].serial), pages[-1])
示例6: _post_tags
# 需要导入模块: from mutagen.ogg import OggPage [as 别名]
# 或者: from mutagen.ogg.OggPage import find_last [as 别名]
def _post_tags(self, fileobj):
if self.length:
return
page = OggPage.find_last(fileobj, self.serial, finishing=True)
if page is None:
raise OggFLACHeaderError
self.length = page.position / float(self.sample_rate)
示例7: test_find_last_single_muxed
# 需要导入模块: from mutagen.ogg import OggPage [as 别名]
# 或者: from mutagen.ogg.OggPage import find_last [as 别名]
def test_find_last_single_muxed(self):
page1 = OggPage()
page1.last = True
page2 = OggPage()
page2.serial = page1.serial + 1
pages = [page1, page2]
data = BytesIO(b"".join([page.write() for page in pages]))
assert OggPage.find_last(data, page2.serial).serial == page2.serial
示例8: test_find_last_muxed
# 需要导入模块: from mutagen.ogg import OggPage [as 别名]
# 或者: from mutagen.ogg.OggPage import find_last [as 别名]
def test_find_last_muxed(self):
pages = [OggPage() for i in range(10)]
for i, page in enumerate(pages): page.sequence = i
pages[-2].last = True
pages[-1].serial = pages[0].serial + 1
data = StringIO("".join([page.write() for page in pages]))
self.failUnlessEqual(
OggPage.find_last(data, pages[0].serial), pages[-2])
示例9: _post_tags
# 需要导入模块: from mutagen.ogg import OggPage [as 别名]
# 或者: from mutagen.ogg.OggPage import find_last [as 别名]
def _post_tags(self, fileobj):
page = OggPage.find_last(fileobj, self.serial)
if page is None:
raise OggTheoraHeaderError
position = page.position
mask = (1 << self.granule_shift) - 1
frames = (position >> self.granule_shift) + (position & mask)
self.length = frames / float(self.fps)
示例10: load
# 需要导入模块: from mutagen.ogg import OggPage [as 别名]
# 或者: from mutagen.ogg.OggPage import find_last [as 别名]
def load(self, fp):
self.filename = fp.name
fileobj = fp
try:
try:
self.info = self._Info(fileobj)
self.tags = self._Tags(fileobj, self.info)
if self.info.length:
return
last_page = OggPage.find_last(fileobj, self.info.serial)
samples = last_page.position
try:
denom = self.info.sample_rate
except AttributeError:
denom = self.info.fps
self.info.length = samples / float(denom)
except OggError, e:
raise self._Error, e, sys.exc_info()[2]
except EOFError:
raise self._Error, "no appropriate stream found"
示例11: _post_tags
# 需要导入模块: from mutagen.ogg import OggPage [as 别名]
# 或者: from mutagen.ogg.OggPage import find_last [as 别名]
def _post_tags(self, fileobj):
page = OggPage.find_last(fileobj, self.serial)
position = page.position
mask = (1 << self.granule_shift) - 1
frames = (position >> self.granule_shift) + (position & mask)
self.length = frames / float(self.fps)
示例12: _post_tags
# 需要导入模块: from mutagen.ogg import OggPage [as 别名]
# 或者: from mutagen.ogg.OggPage import find_last [as 别名]
def _post_tags(self, fileobj):
if self.length:
return
page = OggPage.find_last(fileobj, self.serial)
self.length = page.position / self.sample_rate
示例13: _post_tags
# 需要导入模块: from mutagen.ogg import OggPage [as 别名]
# 或者: from mutagen.ogg.OggPage import find_last [as 别名]
def _post_tags(self, fileobj):
page = OggPage.find_last(fileobj, self.serial)
self.length = page.position / float(self.sample_rate)
示例14: _post_tags
# 需要导入模块: from mutagen.ogg import OggPage [as 别名]
# 或者: from mutagen.ogg.OggPage import find_last [as 别名]
def _post_tags(self, fileobj):
page = OggPage.find_last(fileobj, self.serial)
if page is None:
raise OggSpeexHeaderError
self.length = page.position / float(self.sample_rate)
示例15: _post_tags
# 需要导入模块: from mutagen.ogg import OggPage [as 别名]
# 或者: from mutagen.ogg.OggPage import find_last [as 别名]
def _post_tags(self, fileobj):
page = OggPage.find_last(fileobj, self.serial)
self.length = (page.position - self.__pre_skip) / float(48000)