mirror of
https://github.com/iluvcapra/wavinfo.git
synced 2025-12-31 08:50:41 +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():
|
||||
info = wavinfo.WavInfoReader(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'] )
|
||||
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, '')
|
||||
# these don't always reflect the bext info
|
||||
# self.assertEqual( info.bext.originator_date, ffprobe_info['format']['tags']['date'] )
|
||||
# self.assertEqual( info.bext.originator_time, ffprobe_info['format']['tags']['creation_time'] )
|
||||
self.assertEqual( info.bext.time_reference, int(ffprobe_info['format']['tags']['time_reference']) )
|
||||
|
||||
# these don't always reflect the bext info
|
||||
# self.assertEqual( info.bext.originator_date, ffprobe_info['format']['tags']['date'] )
|
||||
# self.assertEqual( info.bext.originator_time, ffprobe_info['format']['tags']['creation_time'] )
|
||||
self.assertEqual( info.bext.time_reference, int(ffprobe_info['format']['tags']['time_reference']) )
|
||||
|
||||
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, '' )
|
||||
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):
|
||||
expected = {'A101_4.WAV': {'project' : 'BMH', 'scene': 'A101', 'take': '4',
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
import struct
|
||||
|
||||
import pdb
|
||||
from collections import namedtuple
|
||||
|
||||
class ListChunkDescriptor(namedtuple('ListChunkDescriptor' , 'signature children')):
|
||||
@@ -30,11 +30,16 @@ def parse_list_chunk(stream, length):
|
||||
|
||||
children = []
|
||||
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)
|
||||
|
||||
def parse_chunk(stream):
|
||||
#breakpoint()
|
||||
ident = stream.read(4)
|
||||
if len(ident) != 4:
|
||||
return
|
||||
|
||||
@@ -115,7 +115,10 @@ class WavInfoReader():
|
||||
|
||||
def _get_bext(self, f, encoding):
|
||||
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):
|
||||
ixml_data = self._find_chunk_data(b'iXML',f,default_none=True)
|
||||
|
||||
Reference in New Issue
Block a user