mirror of
https://github.com/iluvcapra/wavinfo.git
synced 2026-01-02 01:40:42 +00:00
Fixed an infinite loop
Parsing this new file from soundgrinder seems to be error-prone, for now this fixes it.
This commit is contained in:
@@ -66,23 +66,23 @@ class TestWaveInfo(TestCase):
|
|||||||
for wav_file in self.all_files():
|
for wav_file in self.all_files():
|
||||||
info = wavinfo.WavInfoReader(wav_file)
|
info = wavinfo.WavInfoReader(wav_file)
|
||||||
ffprobe_info = ffprobe(wav_file)
|
ffprobe_info = ffprobe(wav_file)
|
||||||
|
if info.bext:
|
||||||
|
self.assertEqual( info.bext.description, ffprobe_info['format']['tags']['comment'] )
|
||||||
|
self.assertEqual( info.bext.originator, ffprobe_info['format']['tags']['encoded_by'] )
|
||||||
|
if 'originator_reference' in ffprobe_info['format']['tags']:
|
||||||
|
self.assertEqual( info.bext.originator_ref, ffprobe_info['format']['tags']['originator_reference'] )
|
||||||
|
else:
|
||||||
|
self.assertEqual( info.bext.originator_ref, '')
|
||||||
|
|
||||||
self.assertEqual( info.bext.description, ffprobe_info['format']['tags']['comment'] )
|
# these don't always reflect the bext info
|
||||||
self.assertEqual( info.bext.originator, ffprobe_info['format']['tags']['encoded_by'] )
|
# self.assertEqual( info.bext.originator_date, ffprobe_info['format']['tags']['date'] )
|
||||||
if 'originator_reference' in ffprobe_info['format']['tags']:
|
# self.assertEqual( info.bext.originator_time, ffprobe_info['format']['tags']['creation_time'] )
|
||||||
self.assertEqual( info.bext.originator_ref, ffprobe_info['format']['tags']['originator_reference'] )
|
self.assertEqual( info.bext.time_reference, int(ffprobe_info['format']['tags']['time_reference']) )
|
||||||
else:
|
|
||||||
self.assertEqual( info.bext.originator_ref, '')
|
|
||||||
|
|
||||||
# these don't always reflect the bext info
|
if 'coding_history' in ffprobe_info['format']['tags']:
|
||||||
# self.assertEqual( info.bext.originator_date, ffprobe_info['format']['tags']['date'] )
|
self.assertEqual( info.bext.coding_history, ffprobe_info['format']['tags']['coding_history'] )
|
||||||
# self.assertEqual( info.bext.originator_time, ffprobe_info['format']['tags']['creation_time'] )
|
else:
|
||||||
self.assertEqual( info.bext.time_reference, int(ffprobe_info['format']['tags']['time_reference']) )
|
self.assertEqual( info.bext.coding_history, '' )
|
||||||
|
|
||||||
if 'coding_history' in ffprobe_info['format']['tags']:
|
|
||||||
self.assertEqual( info.bext.coding_history, ffprobe_info['format']['tags']['coding_history'] )
|
|
||||||
else:
|
|
||||||
self.assertEqual( info.bext.coding_history, '' )
|
|
||||||
|
|
||||||
def test_ixml(self):
|
def test_ixml(self):
|
||||||
expected = {'A101_4.WAV': {'project' : 'BMH', 'scene': 'A101', 'take': '4',
|
expected = {'A101_4.WAV': {'project' : 'BMH', 'scene': 'A101', 'take': '4',
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
import struct
|
import struct
|
||||||
|
import pdb
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
class ListChunkDescriptor(namedtuple('ListChunkDescriptor' , 'signature children')):
|
class ListChunkDescriptor(namedtuple('ListChunkDescriptor' , 'signature children')):
|
||||||
@@ -30,11 +30,16 @@ def parse_list_chunk(stream, length):
|
|||||||
|
|
||||||
children = []
|
children = []
|
||||||
while (stream.tell() - start) < length:
|
while (stream.tell() - start) < length:
|
||||||
children.append(parse_chunk(stream))
|
child_chunk = parse_chunk(stream)
|
||||||
|
if child_chunk:
|
||||||
|
children.append(child_chunk)
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
|
||||||
return ListChunkDescriptor(signature=signature, children=children)
|
return ListChunkDescriptor(signature=signature, children=children)
|
||||||
|
|
||||||
def parse_chunk(stream):
|
def parse_chunk(stream):
|
||||||
|
#breakpoint()
|
||||||
ident = stream.read(4)
|
ident = stream.read(4)
|
||||||
if len(ident) != 4:
|
if len(ident) != 4:
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -115,7 +115,10 @@ class WavInfoReader():
|
|||||||
|
|
||||||
def _get_bext(self, f, encoding):
|
def _get_bext(self, f, encoding):
|
||||||
bext_data = self._find_chunk_data(b'bext',f,default_none=True)
|
bext_data = self._find_chunk_data(b'bext',f,default_none=True)
|
||||||
return WavBextReader(bext_data, encoding)
|
if bext_data:
|
||||||
|
return WavBextReader(bext_data, encoding)
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
def _get_ixml(self,f):
|
def _get_ixml(self,f):
|
||||||
ixml_data = self._find_chunk_data(b'iXML',f,default_none=True)
|
ixml_data = self._find_chunk_data(b'iXML',f,default_none=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user