From 5c90d5ff4796664a28a305f02dd6f23f45613f6c Mon Sep 17 00:00:00 2001 From: Jamie Hardt Date: Thu, 2 Jan 2020 11:44:42 -0800 Subject: [PATCH] Rewrite of chink code More work on #4 --- setup.py | 2 +- wavinfo/riff_parser.py | 32 +++++++++++++++----------------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/setup.py b/setup.py index d5157c3..edab1bb 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ with open("README.md", "r") as fh: long_description = fh.read() setup(name='wavinfo', - version='1.3', + version='1.3.1', author='Jamie Hardt', author_email='jamiehardt@me.com', description='Probe WAVE Files for iXML, Broadcast-WAVE and other metadata.', diff --git a/wavinfo/riff_parser.py b/wavinfo/riff_parser.py index 21833a7..6366ae5 100644 --- a/wavinfo/riff_parser.py +++ b/wavinfo/riff_parser.py @@ -32,43 +32,41 @@ class ChunkDescriptor(namedtuple('ChunkDescriptor', 'ident start length rf64_con def parse_list_chunk(stream, length, rf64_context=None): start = stream.tell() - signature = stream.read(4) children = [] - while (stream.tell() - start) < length: + while (stream.tell() - start + 8) < length: child_chunk = parse_chunk(stream, rf64_context=rf64_context) - if child_chunk: - children.append(child_chunk) - else: - break + children.append(child_chunk) + + stream.seek(start + length) return ListChunkDescriptor(signature=signature, children=children) def parse_chunk(stream, rf64_context=None): + header_start = stream.tell() ident = stream.read(4) size_bytes = stream.read(4) - if len(ident) != 4 or len(size_bytes) < 4: - raise WavInfoEOFError(identifier=ident, chunk_start=stream.tell() - 4) + if len(ident) != 4 or len(size_bytes) != 4: + raise WavInfoEOFError(identifier=ident, chunk_start=header_start) - size_bytes = stream.read(4) - size = struct.unpack('