mirror of
https://github.com/iluvcapra/wavinfo.git
synced 2025-12-31 08:50:41 +00:00
In-progress flake8 fixes
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
from optparse import OptionParser, OptionGroup
|
||||
import datetime
|
||||
from . import WavInfoReader
|
||||
from . import __version__
|
||||
|
||||
from optparse import OptionParser
|
||||
import sys
|
||||
import json
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class MyJSONEncoder(json.JSONEncoder):
|
||||
def default(self, o):
|
||||
if isinstance(o, Enum):
|
||||
@@ -13,23 +15,25 @@ class MyJSONEncoder(json.JSONEncoder):
|
||||
else:
|
||||
return super().default(o)
|
||||
|
||||
|
||||
class MissingDataError(RuntimeError):
|
||||
pass
|
||||
|
||||
|
||||
def main():
|
||||
parser = OptionParser()
|
||||
|
||||
parser.usage = 'wavinfo (--adm | --ixml) <FILE> +'
|
||||
|
||||
# parser.add_option('-f', dest='output_format', help='Set the output format',
|
||||
# default='json',
|
||||
# metavar='FORMAT')
|
||||
parser.add_option('--adm', dest='adm',
|
||||
help='Output ADM XML',
|
||||
default=False,
|
||||
action='store_true')
|
||||
|
||||
parser.add_option('--adm', dest='adm', help='Output ADM XML',
|
||||
default=False, action='store_true')
|
||||
|
||||
parser.add_option('--ixml', dest='ixml', help='Output iXML',
|
||||
default=False, action='store_true')
|
||||
parser.add_option('--ixml', dest='ixml',
|
||||
help='Output iXML',
|
||||
default=False,
|
||||
action='store_true')
|
||||
|
||||
(options, args) = parser.parse_args(sys.argv)
|
||||
for arg in args[1:]:
|
||||
@@ -48,7 +52,7 @@ def main():
|
||||
else:
|
||||
ret_dict = {
|
||||
'filename': arg,
|
||||
'run_date': datetime.datetime.now().isoformat() ,
|
||||
'run_date': datetime.datetime.now().isoformat(),
|
||||
'application': "wavinfo " + __version__,
|
||||
'scopes': {}
|
||||
}
|
||||
@@ -60,7 +64,7 @@ def main():
|
||||
|
||||
json.dump(ret_dict, cls=MyJSONEncoder, fp=sys.stdout, indent=2)
|
||||
except MissingDataError as e:
|
||||
print("MissingDataError: Missing metadata (%s) in file %s" % \
|
||||
print("MissingDataError: Missing metadata (%s) in file %s" %
|
||||
(e, arg), file=sys.stderr)
|
||||
continue
|
||||
except Exception as e:
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
import struct
|
||||
from collections import namedtuple
|
||||
# from collections import namedtuple
|
||||
from typing import NamedTuple, Dict
|
||||
|
||||
from . import riff_parser
|
||||
|
||||
RF64Context = namedtuple('RF64Context','sample_count bigchunk_table')
|
||||
|
||||
class RF64Context(NamedTuple):
|
||||
sample_count: int
|
||||
bigchunk_table: Dict[str, int]
|
||||
|
||||
|
||||
def parse_rf64(stream, signature = b'RF64') -> RF64Context:
|
||||
def parse_rf64(stream, signature=b'RF64') -> RF64Context:
|
||||
start = stream.tell()
|
||||
assert( stream.read(4) == b'WAVE' )
|
||||
assert stream.read(4) == b'WAVE'
|
||||
|
||||
ds64_chunk = riff_parser.parse_chunk(stream)
|
||||
assert type(ds64_chunk) is riff_parser.ChunkDescriptor, \
|
||||
@@ -16,10 +20,10 @@ def parse_rf64(stream, signature = b'RF64') -> RF64Context:
|
||||
|
||||
ds64_field_spec = "<QQQI"
|
||||
ds64_fields_size = struct.calcsize(ds64_field_spec)
|
||||
assert(ds64_chunk.ident == b'ds64')
|
||||
assert ds64_chunk.ident == b'ds64'
|
||||
|
||||
ds64_data = ds64_chunk.read_data(stream)
|
||||
assert(len(ds64_data) >= ds64_fields_size)
|
||||
assert len(ds64_data) >= ds64_fields_size
|
||||
|
||||
riff_size, data_size, sample_count, length_lookup_table = struct.unpack(
|
||||
ds64_field_spec, ds64_data[0:ds64_fields_size]
|
||||
@@ -30,14 +34,14 @@ def parse_rf64(stream, signature = b'RF64') -> RF64Context:
|
||||
# chunksize64size = struct.calcsize(chunksize64format)
|
||||
|
||||
for _ in range(length_lookup_table):
|
||||
bigname, bigsize = struct.unpack_from(chunksize64format, ds64_data,
|
||||
offset= ds64_fields_size)
|
||||
bigname, bigsize = struct.unpack_from(chunksize64format,
|
||||
ds64_data,
|
||||
offset=ds64_fields_size)
|
||||
bigchunk_table[bigname] = bigsize
|
||||
|
||||
bigchunk_table[b'data'] = data_size
|
||||
bigchunk_table[signature] = riff_size
|
||||
|
||||
stream.seek(start, 0)
|
||||
return RF64Context( sample_count=sample_count,
|
||||
return RF64Context(sample_count=sample_count,
|
||||
bigchunk_table=bigchunk_table)
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
|
||||
from optparse import Option
|
||||
# from optparse import Option
|
||||
import struct
|
||||
from .rf64_parser import parse_rf64, RF64Context
|
||||
from typing import NamedTuple, Union, List, Optional
|
||||
@@ -56,7 +55,7 @@ def parse_chunk(stream, rf64_context=None):
|
||||
rf64_context = parse_rf64(stream=stream, signature=ident)
|
||||
|
||||
assert rf64_context is not None, \
|
||||
f"Sentinel data size 0xFFFFFFFF found outside of RF64 context"
|
||||
"Sentinel data size 0xFFFFFFFF found outside of RF64 context"
|
||||
|
||||
data_size = rf64_context.bigchunk_table[ident]
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
|
||||
# def binary_to_string(binary_value):
|
||||
# return reduce(lambda val, el: val + "{:02x}".format(el), binary_value, '')
|
||||
|
||||
# return reduce(lambda val, el: val + "{:02x}".format(el),
|
||||
# binary_value, '')
|
||||
|
||||
# class UMIDParser:
|
||||
# """
|
||||
@@ -13,109 +13,109 @@
|
||||
# """
|
||||
# def __init__(self, raw_umid: bytes):
|
||||
# self.raw_umid = raw_umid
|
||||
#
|
||||
# @property
|
||||
# def universal_label(self) -> bytearray:
|
||||
# return self.raw_umid[0:12]
|
||||
#
|
||||
# @property
|
||||
# def basic_umid(self):
|
||||
# return self.raw_umid[0:32]
|
||||
#
|
||||
# @property
|
||||
# def universal_label(self) -> bytearray:
|
||||
# return self.raw_umid[0:12]
|
||||
#
|
||||
# @property
|
||||
# def basic_umid(self):
|
||||
# return self.raw_umid[0:32]
|
||||
|
||||
# def basic_umid_to_str(self):
|
||||
# return binary_to_string(self.raw_umid[0:32])
|
||||
#
|
||||
# @property
|
||||
# def universal_label_is_valid(self) -> bool:
|
||||
# valid_preamble = b'\x06\x0a\x2b\x34\x01\x01\x01\x05\x01\x01'
|
||||
# return self.universal_label[0:len(valid_preamble)] == valid_preamble
|
||||
#
|
||||
# @property
|
||||
# def material_type(self) -> str:
|
||||
# material_byte = self.raw_umid[10]
|
||||
# if material_byte == 0x1:
|
||||
# return 'picture'
|
||||
# elif material_byte == 0x2:
|
||||
# return 'audio'
|
||||
# elif material_byte == 0x3:
|
||||
# return 'data'
|
||||
# elif material_byte == 0x4:
|
||||
# return 'other'
|
||||
# elif material_byte == 0x5:
|
||||
# return 'picture_single_component'
|
||||
# elif material_byte == 0x6:
|
||||
# return 'picture_multiple_component'
|
||||
# elif material_byte == 0x7:
|
||||
# return 'audio_single_component'
|
||||
# elif material_byte == 0x9:
|
||||
# return 'audio_multiple_component'
|
||||
# elif material_byte == 0xb:
|
||||
# return 'auxiliary_single_component'
|
||||
# elif material_byte == 0xc:
|
||||
# return 'auxiliary_multiple_component'
|
||||
# elif material_byte == 0xd:
|
||||
# return 'mixed_components'
|
||||
# elif material_byte == 0xf:
|
||||
# return 'not_identified'
|
||||
# else:
|
||||
# return 'not_recognized'
|
||||
#
|
||||
# @property
|
||||
# def material_number_creation_method(self) -> str:
|
||||
# method_byte = self.raw_umid[11]
|
||||
# method_byte = (method_byte << 4) & 0xf
|
||||
# if method_byte == 0x0:
|
||||
# return 'undefined'
|
||||
# elif method_byte == 0x1:
|
||||
# return 'smpte'
|
||||
# elif method_byte == 0x2:
|
||||
# return 'uuid'
|
||||
# elif method_byte == 0x3:
|
||||
# return 'masked'
|
||||
# elif method_byte == 0x4:
|
||||
# return 'ieee1394'
|
||||
# elif 0x5 <= method_byte <= 0x7:
|
||||
# return 'reserved_undefined'
|
||||
# else:
|
||||
# return 'unrecognized'
|
||||
#
|
||||
# @property
|
||||
# def instance_number_creation_method(self) -> str:
|
||||
# method_byte = self.raw_umid[11]
|
||||
# method_byte = method_byte & 0xf
|
||||
# if method_byte == 0x0:
|
||||
# return 'undefined'
|
||||
# elif method_byte == 0x01:
|
||||
# return 'local_registration'
|
||||
# elif method_byte == 0x02:
|
||||
# return '24_bit_prs'
|
||||
# elif method_byte == 0x03:
|
||||
# return 'copy_number_and_16_bit_prs'
|
||||
# elif 0x04 <= method_byte <= 0x0e:
|
||||
# return 'reserved_undefined'
|
||||
# elif method_byte == 0x0f:
|
||||
# return 'live_stream'
|
||||
# else:
|
||||
# return 'unrecognized'
|
||||
#
|
||||
# @property
|
||||
# def indicated_length(self) -> str:
|
||||
# if self.raw_umid[12] == 0x13:
|
||||
# return 'basic'
|
||||
# elif self.raw_umid[12] == 0x33:
|
||||
# return 'extended'
|
||||
#
|
||||
# @property
|
||||
# def instance_number(self) -> bytearray:
|
||||
# return self.raw_umid[13:3]
|
||||
#
|
||||
# @property
|
||||
# def material_number(self) -> bytearray:
|
||||
# return self.raw_umid[16:16]
|
||||
#
|
||||
# @property
|
||||
# def source_pack(self) -> Union[bytearray, None]:
|
||||
# if self.indicated_length == 'extended':
|
||||
# return self.raw_umid[32:32]
|
||||
# else:
|
||||
# return None
|
||||
# def basic_umid_to_str(self):
|
||||
# return binary_to_string(self.raw_umid[0:32])
|
||||
#
|
||||
# @property
|
||||
# def universal_label_is_valid(self) -> bool:
|
||||
# valid_preamble = b'\x06\x0a\x2b\x34\x01\x01\x01\x05\x01\x01'
|
||||
# return self.universal_label[0:len(valid_preamble)] == valid_preamble
|
||||
#
|
||||
# @property
|
||||
# def material_type(self) -> str:
|
||||
# material_byte = self.raw_umid[10]
|
||||
# if material_byte == 0x1:
|
||||
# return 'picture'
|
||||
# elif material_byte == 0x2:
|
||||
# return 'audio'
|
||||
# elif material_byte == 0x3:
|
||||
# return 'data'
|
||||
# elif material_byte == 0x4:
|
||||
# return 'other'
|
||||
# elif material_byte == 0x5:
|
||||
# return 'picture_single_component'
|
||||
# elif material_byte == 0x6:
|
||||
# return 'picture_multiple_component'
|
||||
# elif material_byte == 0x7:
|
||||
# return 'audio_single_component'
|
||||
# elif material_byte == 0x9:
|
||||
# return 'audio_multiple_component'
|
||||
# elif material_byte == 0xb:
|
||||
# return 'auxiliary_single_component'
|
||||
# elif material_byte == 0xc:
|
||||
# return 'auxiliary_multiple_component'
|
||||
# elif material_byte == 0xd:
|
||||
# return 'mixed_components'
|
||||
# elif material_byte == 0xf:
|
||||
# return 'not_identified'
|
||||
# else:
|
||||
# return 'not_recognized'
|
||||
#
|
||||
# @property
|
||||
# def material_number_creation_method(self) -> str:
|
||||
# method_byte = self.raw_umid[11]
|
||||
# method_byte = (method_byte << 4) & 0xf
|
||||
# if method_byte == 0x0:
|
||||
# return 'undefined'
|
||||
# elif method_byte == 0x1:
|
||||
# return 'smpte'
|
||||
# elif method_byte == 0x2:
|
||||
# return 'uuid'
|
||||
# elif method_byte == 0x3:
|
||||
# return 'masked'
|
||||
# elif method_byte == 0x4:
|
||||
# return 'ieee1394'
|
||||
# elif 0x5 <= method_byte <= 0x7:
|
||||
# return 'reserved_undefined'
|
||||
# else:
|
||||
# return 'unrecognized'
|
||||
#
|
||||
# @property
|
||||
# def instance_number_creation_method(self) -> str:
|
||||
# method_byte = self.raw_umid[11]
|
||||
# method_byte = method_byte & 0xf
|
||||
# if method_byte == 0x0:
|
||||
# return 'undefined'
|
||||
# elif method_byte == 0x01:
|
||||
# return 'local_registration'
|
||||
# elif method_byte == 0x02:
|
||||
# return '24_bit_prs'
|
||||
# elif method_byte == 0x03:
|
||||
# return 'copy_number_and_16_bit_prs'
|
||||
# elif 0x04 <= method_byte <= 0x0e:
|
||||
# return 'reserved_undefined'
|
||||
# elif method_byte == 0x0f:
|
||||
# return 'live_stream'
|
||||
# else:
|
||||
# return 'unrecognized'
|
||||
#
|
||||
# @property
|
||||
# def indicated_length(self) -> str:
|
||||
# if self.raw_umid[12] == 0x13:
|
||||
# return 'basic'
|
||||
# elif self.raw_umid[12] == 0x33:
|
||||
# return 'extended'
|
||||
#
|
||||
# @property
|
||||
# def instance_number(self) -> bytearray:
|
||||
# return self.raw_umid[13:3]
|
||||
#
|
||||
# @property
|
||||
# def material_number(self) -> bytearray:
|
||||
# return self.raw_umid[16:16]
|
||||
#
|
||||
# @property
|
||||
# def source_pack(self) -> Union[bytearray, None]:
|
||||
# if self.indicated_length == 'extended':
|
||||
# return self.raw_umid[32:32]
|
||||
# else:
|
||||
# return None
|
||||
|
||||
@@ -9,8 +9,10 @@ from typing import Optional
|
||||
|
||||
from lxml import etree as ET
|
||||
|
||||
|
||||
ChannelEntry = namedtuple('ChannelEntry', "track_index uid track_ref pack_ref")
|
||||
|
||||
|
||||
class WavADMReader:
|
||||
"""
|
||||
Reads XML data from an EBU ADM (Audio Definiton Model) WAV File.
|
||||
@@ -37,9 +39,13 @@ class WavADMReader:
|
||||
|
||||
# these values are either ascii or all null
|
||||
|
||||
self.channel_uids.append(ChannelEntry(track_index - 1,
|
||||
uid.decode('ascii') , track_ref.decode('ascii'),
|
||||
pack_ref.decode('ascii')))
|
||||
self.channel_uids.append(
|
||||
ChannelEntry(track_index - 1,
|
||||
uid.decode('ascii'),
|
||||
track_ref.decode('ascii'),
|
||||
pack_ref.decode('ascii')
|
||||
)
|
||||
)
|
||||
|
||||
offset += calcsize(uid_fmt)
|
||||
|
||||
@@ -105,7 +111,7 @@ class WavADMReader:
|
||||
*object_name*, *object_id*,
|
||||
*pack_format_name*, *pack_type*, *channel_format_name*
|
||||
"""
|
||||
channel_info = next((x for x in self.channel_uids \
|
||||
channel_info = next((x for x in self.channel_uids
|
||||
if x.track_index == index), None)
|
||||
|
||||
if channel_info is None:
|
||||
@@ -115,12 +121,12 @@ class WavADMReader:
|
||||
|
||||
nsmap = self.axml.getroot().nsmap
|
||||
|
||||
afext = self.axml.find(".//audioFormatExtended", namespaces=nsmap)
|
||||
afext = self.axml.find(".//audioFormatExtended",
|
||||
namespaces=nsmap)
|
||||
|
||||
trackformat_elem = afext.find(
|
||||
"audioTrackFormat[@audioTrackFormatID='%s']" \
|
||||
% channel_info.track_ref,
|
||||
namespaces=nsmap)
|
||||
"audioTrackFormat[@audioTrackFormatID='%s']"
|
||||
% channel_info.track_ref, namespaces=nsmap)
|
||||
|
||||
stream_id = trackformat_elem[0].text
|
||||
|
||||
@@ -130,14 +136,14 @@ class WavADMReader:
|
||||
namespaces=nsmap)
|
||||
channelformat_id = channelformatref_elem.text
|
||||
|
||||
packformatref_elem = afext\
|
||||
.find(("audioStreamFormat[@audioStreamFormatID='%s']"
|
||||
packformatref_elem = afext.find(
|
||||
("audioStreamFormat[@audioStreamFormatID='%s']"
|
||||
"/audioPackFormatIDRef") % stream_id,
|
||||
namespaces=nsmap)
|
||||
packformat_id = packformatref_elem.text
|
||||
|
||||
channelformat_elem = afext\
|
||||
.find("audioChannelFormat[@audioChannelFormatID='%s']" \
|
||||
.find("audioChannelFormat[@audioChannelFormatID='%s']"
|
||||
% channelformat_id,
|
||||
namespaces=nsmap)
|
||||
ret_dict['channel_format_name'] = channelformat_elem.get(
|
||||
@@ -151,7 +157,7 @@ class WavADMReader:
|
||||
ret_dict['pack_format_name'] = packformat_elem.get(
|
||||
"audioPackFormatName")
|
||||
|
||||
object_elem = afext.find("audioObject[audioPackFormatIDRef = '%s']" \
|
||||
object_elem = afext.find("audioObject[audioPackFormatIDRef = '%s']"
|
||||
% packformat_id,
|
||||
namespaces=nsmap)
|
||||
|
||||
@@ -159,7 +165,7 @@ class WavADMReader:
|
||||
object_id = object_elem.get("audioObjectID")
|
||||
ret_dict['object_id'] = object_id
|
||||
|
||||
content_elem = afext.find("audioContent/[audioObjectIDRef = '%s']" \
|
||||
content_elem = afext.find("audioContent/[audioObjectIDRef = '%s']"
|
||||
% object_id,
|
||||
namespaces=nsmap)
|
||||
|
||||
@@ -168,7 +174,7 @@ class WavADMReader:
|
||||
|
||||
return ret_dict
|
||||
|
||||
def to_dict(self) -> dict: #FIXME should be "asdict"
|
||||
def to_dict(self) -> dict: # FIXME should be "asdict"
|
||||
"""
|
||||
Get ADM metadata as a dictionary.
|
||||
"""
|
||||
|
||||
@@ -3,6 +3,7 @@ import struct
|
||||
|
||||
from typing import Optional
|
||||
|
||||
|
||||
class WavBextReader:
|
||||
def __init__(self, bext_data, encoding):
|
||||
"""
|
||||
@@ -18,59 +19,59 @@ class WavBextReader:
|
||||
rest_starts = struct.calcsize(packstring)
|
||||
unpacked = struct.unpack(packstring, bext_data[:rest_starts])
|
||||
|
||||
def sanitize_bytes(b : bytes) -> str:
|
||||
def sanitize_bytes(b: bytes) -> str:
|
||||
# honestly can't remember why I'm stripping nulls this way
|
||||
first_null = next((index for index, byte in enumerate(b) \
|
||||
first_null = next((index for index, byte in enumerate(b)
|
||||
if byte == 0), None)
|
||||
trimmed = b if first_null is None else b[:first_null]
|
||||
decoded = trimmed.decode(encoding)
|
||||
return decoded
|
||||
|
||||
#: Description. A free-text field up to 256 characters long.
|
||||
self.description : str = sanitize_bytes(unpacked[0])
|
||||
self.description: str = sanitize_bytes(unpacked[0])
|
||||
|
||||
#: Originator. Usually the name of the encoding application, sometimes
|
||||
#: an artist name.
|
||||
self.originator : str = sanitize_bytes(unpacked[1])
|
||||
self.originator: str = sanitize_bytes(unpacked[1])
|
||||
|
||||
#: A unique identifier for the file, a serial number.
|
||||
self.originator_ref : str = sanitize_bytes(unpacked[2])
|
||||
self.originator_ref: str = sanitize_bytes(unpacked[2])
|
||||
|
||||
#: Date of the recording, in the format YYYY-MM-DD.
|
||||
self.originator_date : str = sanitize_bytes(unpacked[3])
|
||||
self.originator_date: str = sanitize_bytes(unpacked[3])
|
||||
|
||||
#: Time of the recording, in the format HH:MM:SS.
|
||||
self.originator_time : str = sanitize_bytes(unpacked[4])
|
||||
self.originator_time: str = sanitize_bytes(unpacked[4])
|
||||
|
||||
#: The sample offset of the start, usually relative
|
||||
#: to midnight.
|
||||
self.time_reference : int = unpacked[5]
|
||||
self.time_reference: int = unpacked[5]
|
||||
|
||||
#: A variable-length text field containing a list of processes and
|
||||
#: and conversions performed on the file.
|
||||
self.coding_history : str = sanitize_bytes(bext_data[rest_starts:])
|
||||
self.coding_history: str = sanitize_bytes(bext_data[rest_starts:])
|
||||
|
||||
#: BEXT version.
|
||||
self.version : int = unpacked[6]
|
||||
self.version: int = unpacked[6]
|
||||
|
||||
#: SMPTE 330M UMID of this audio file, 64 bytes are allocated though
|
||||
#: the UMID may only be 32 bytes long.
|
||||
self.umid : Optional[bytes] = None
|
||||
self.umid: Optional[bytes] = None
|
||||
|
||||
#: EBU R128 Integrated loudness, in LUFS.
|
||||
self.loudness_value : Optional[float] = None
|
||||
self.loudness_value: Optional[float] = None
|
||||
|
||||
#: EBU R128 Loudness range, in LUFS.
|
||||
self.loudness_range : Optional[float] = None
|
||||
self.loudness_range: Optional[float] = None
|
||||
|
||||
#: True peak level, in dBFS TP
|
||||
self.max_true_peak : Optional[float] = None
|
||||
self.max_true_peak: Optional[float] = None
|
||||
|
||||
#: EBU R128 Maximum momentary loudness, in LUFS
|
||||
self.max_momentary_loudness : Optional[float] = None
|
||||
self.max_momentary_loudness: Optional[float] = None
|
||||
|
||||
#: EBU R128 Maximum short-term loudness, in LUFS.
|
||||
self.max_shortterm_loudness : Optional[float] = None
|
||||
self.max_shortterm_loudness: Optional[float] = None
|
||||
|
||||
if self.version > 0:
|
||||
self.umid = unpacked[7]
|
||||
|
||||
@@ -8,7 +8,6 @@ IBM Corporation and Microsoft Corporation
|
||||
https://www.aelius.com/njh/wavemetatools/doc/riffmci.pdf
|
||||
"""
|
||||
from dataclasses import dataclass
|
||||
import encodings
|
||||
from .riff_parser import ChunkDescriptor
|
||||
|
||||
from struct import unpack, calcsize
|
||||
@@ -252,8 +251,8 @@ class WavCuesReader:
|
||||
:returns: a tuple of the the cue's label (if present) and note (if
|
||||
present)
|
||||
"""
|
||||
label = next((l.text for l in self.labels
|
||||
if l.name == cue_ident), None)
|
||||
label = next((label.text for label in self.labels
|
||||
if label.name == cue_ident), None)
|
||||
note = next((n.text for n in self.notes
|
||||
if n.name == cue_ident), None)
|
||||
return (label, note)
|
||||
@@ -285,4 +284,3 @@ class WavCuesReader:
|
||||
retval[n]['length'] = r
|
||||
|
||||
return retval
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ from typing import List, Tuple, Any, Union
|
||||
|
||||
from io import BytesIO
|
||||
|
||||
|
||||
class SegmentType(IntEnum):
|
||||
"""
|
||||
Metadata segment type.
|
||||
@@ -31,7 +32,7 @@ class SegmentType(IntEnum):
|
||||
DolbyAtmosSupplemental = 0xa
|
||||
|
||||
@classmethod
|
||||
def _missing_(cls,val):
|
||||
def _missing_(cls, val):
|
||||
return val
|
||||
|
||||
|
||||
@@ -77,7 +78,6 @@ class DolbyDigitalPlusMetadata:
|
||||
MUTE = 0b111
|
||||
"-∞ dB"
|
||||
|
||||
|
||||
class DolbySurroundEncodingMode(Enum):
|
||||
"""
|
||||
Dolby surround endcoding mode.
|
||||
@@ -87,7 +87,6 @@ class DolbyDigitalPlusMetadata:
|
||||
NOT_IN_USE = 0b01
|
||||
NOT_INDICATED = 0b00
|
||||
|
||||
|
||||
class BitStreamMode(Enum):
|
||||
"""
|
||||
Dolby Digital Plus `bsmod` field
|
||||
@@ -122,7 +121,6 @@ class DolbyDigitalPlusMetadata:
|
||||
should be interpreted as karaoke.
|
||||
"""
|
||||
|
||||
|
||||
class AudioCodingMode(Enum):
|
||||
"""
|
||||
Dolby Digital Plus `acmod` field
|
||||
@@ -144,7 +142,6 @@ class DolbyDigitalPlusMetadata:
|
||||
CH_ORD_3_2 = 0b111
|
||||
"LCR + LR surround"
|
||||
|
||||
|
||||
class CenterDownMixLevel(Enum):
|
||||
"""
|
||||
§ 4.3.3.1
|
||||
@@ -161,7 +158,6 @@ class DolbyDigitalPlusMetadata:
|
||||
|
||||
RESERVED = 0b11
|
||||
|
||||
|
||||
class SurroundDownMixLevel(Enum):
|
||||
"""
|
||||
Dolby Digital Plus `surmixlev` field
|
||||
@@ -172,7 +168,6 @@ class DolbyDigitalPlusMetadata:
|
||||
MUTE = 0b10
|
||||
RESERVED = 0b11
|
||||
|
||||
|
||||
class LanguageCode(int):
|
||||
"""
|
||||
§ 4.3.4.1
|
||||
@@ -181,21 +176,18 @@ class DolbyDigitalPlusMetadata:
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
class MixLevel(int):
|
||||
"""
|
||||
§ 4.3.6.2
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
class DialnormLevel(int):
|
||||
"""
|
||||
§ 4.3.4.4
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
class RoomType(Enum):
|
||||
"""
|
||||
`roomtyp` 4.3.6.3
|
||||
@@ -205,7 +197,6 @@ class DolbyDigitalPlusMetadata:
|
||||
SMALL_ROOM_FLAT_CURVE = 0b10
|
||||
RESERVED = 0b11
|
||||
|
||||
|
||||
class PreferredDownMixMode(Enum):
|
||||
"""
|
||||
Indicates the creating engineer's preference of what the receiver
|
||||
@@ -217,7 +208,6 @@ class DolbyDigitalPlusMetadata:
|
||||
STEREO = 0b10
|
||||
PRO_LOGIC_2 = 0b11
|
||||
|
||||
|
||||
class SurroundEXMode(IntEnum):
|
||||
"""
|
||||
Dolby Surround-EX mode.
|
||||
@@ -228,7 +218,6 @@ class DolbyDigitalPlusMetadata:
|
||||
SEX = 0b10
|
||||
PRO_LOGIC_2 = 0b11
|
||||
|
||||
|
||||
class HeadphoneMode(IntEnum):
|
||||
"""
|
||||
`dheadphonmod` § 4.3.9.2
|
||||
@@ -238,12 +227,10 @@ class DolbyDigitalPlusMetadata:
|
||||
DOLBY_HEADPHONE = 0b10
|
||||
RESERVED = 0b11
|
||||
|
||||
|
||||
class ADConverterType(Enum):
|
||||
STANDARD = 0
|
||||
HDCD = 1
|
||||
|
||||
|
||||
class StreamDependency(Enum):
|
||||
"""
|
||||
Encodes `ddplus_info1.stream_type` field § 4.3.12.1
|
||||
@@ -254,7 +241,6 @@ class DolbyDigitalPlusMetadata:
|
||||
INDEPENDENT_FROM_DOLBY_DIGITAL = 2
|
||||
RESERVED = 3
|
||||
|
||||
|
||||
class RFCompressionProfile(Enum):
|
||||
"""
|
||||
`compr1` RF compression profile
|
||||
@@ -363,12 +349,15 @@ class DolbyDigitalPlusMetadata:
|
||||
pass
|
||||
|
||||
def surround_config(b):
|
||||
return DolbyDigitalPlusMetadata.CenterDownMixLevel(b & 0x30 >> 4), \
|
||||
DolbyDigitalPlusMetadata.SurroundDownMixLevel(b & 0xc >> 2), \
|
||||
DolbyDigitalPlusMetadata.DolbySurroundEncodingMode(b & 0x3)
|
||||
return DolbyDigitalPlusMetadata\
|
||||
.CenterDownMixLevel(b & 0x30 >> 4),\
|
||||
DolbyDigitalPlusMetadata\
|
||||
.SurroundDownMixLevel(b & 0xc >> 2), \
|
||||
DolbyDigitalPlusMetadata\
|
||||
.DolbySurroundEncodingMode(b & 0x3)
|
||||
|
||||
def dialnorm_info(b):
|
||||
return (b & 0x80) > 0 , b & 0x40 > 0, b & 0x20 > 0, \
|
||||
return (b & 0x80) > 0, b & 0x40 > 0, b & 0x20 > 0, \
|
||||
DolbyDigitalPlusMetadata.DialnormLevel(b & 0x1f)
|
||||
|
||||
def langcod(b) -> int:
|
||||
@@ -391,11 +380,11 @@ class DolbyDigitalPlusMetadata:
|
||||
DolbyDigitalPlusMetadata.DownMixLevelToken(b & 0x38 >> 3), \
|
||||
DolbyDigitalPlusMetadata.DownMixLevelToken(b & 0x7)
|
||||
|
||||
#surround_ex_mode, dolby_headphone_encoded, ad_converter_type
|
||||
# surround_ex_mode, dolby_headphone_encoded, ad_converter_type
|
||||
def ext_bsi2_word1(b):
|
||||
return DolbyDigitalPlusMetadata.SurroundEXMode(b & 0x60 >> 5), \
|
||||
DolbyDigitalPlusMetadata.HeadphoneMode(b & 0x18 >> 3), \
|
||||
DolbyDigitalPlusMetadata.ADConverterType( b & 0x4 >> 2)
|
||||
DolbyDigitalPlusMetadata.ADConverterType(b & 0x4 >> 2)
|
||||
|
||||
def ddplus_reserved2(_):
|
||||
pass
|
||||
@@ -492,7 +481,7 @@ class DolbyAtmosMetadata:
|
||||
NOT_INDICATED = 0x04
|
||||
|
||||
tool_name: str
|
||||
tool_version: Tuple[int,int,int]
|
||||
tool_version: Tuple[int, int, int]
|
||||
warp_mode: WarpMode
|
||||
|
||||
SEGMENT_LENGTH = 248
|
||||
@@ -521,7 +510,7 @@ class DolbyAtmosMetadata:
|
||||
|
||||
return DolbyAtmosMetadata(tool_name=toolname,
|
||||
tool_version=(major, minor, fix),
|
||||
warp_mode=DolbyAtmosMetadata\
|
||||
warp_mode=DolbyAtmosMetadata
|
||||
.WarpMode(warp_mode))
|
||||
|
||||
|
||||
@@ -541,12 +530,10 @@ class DolbyAtmosSupplementalMetadata:
|
||||
MID = 0x03
|
||||
NOT_INDICATED = 0x04
|
||||
|
||||
|
||||
object_count: int
|
||||
render_modes: List['DolbyAtmosSupplementalMetadata.BinauralRenderMode']
|
||||
trim_modes: List[int]
|
||||
|
||||
|
||||
MAGIC = 0xf8726fbd
|
||||
TRIM_CONFIG_COUNT = 9
|
||||
|
||||
@@ -562,13 +549,13 @@ class DolbyAtmosSupplementalMetadata:
|
||||
|
||||
object_count = unpack("<H", h.read(2))[0]
|
||||
|
||||
h.read(1) #skip 1
|
||||
h.read(1) # skip 1
|
||||
|
||||
for _ in range(cls.TRIM_CONFIG_COUNT):
|
||||
auto_trim = unpack("B", h.read(1))
|
||||
trim_modes.append(auto_trim)
|
||||
|
||||
h.read(14) #skip 14
|
||||
h.read(14) # skip 14
|
||||
|
||||
h.read(object_count) # skip object_count bytes
|
||||
|
||||
@@ -578,7 +565,7 @@ class DolbyAtmosSupplementalMetadata:
|
||||
render_modes.append(binaural_mode)
|
||||
|
||||
return DolbyAtmosSupplementalMetadata(object_count=object_count,
|
||||
render_modes=render_modes,trim_modes=trim_modes)
|
||||
render_modes=render_modes, trim_modes=trim_modes)
|
||||
|
||||
|
||||
class WavDolbyMetadataReader:
|
||||
@@ -594,7 +581,7 @@ class WavDolbyMetadataReader:
|
||||
#: not recognized).
|
||||
segment_list: List[Tuple[Union[SegmentType, int], bool, Any]]
|
||||
|
||||
version: Tuple[int,int,int,int]
|
||||
version: Tuple[int, int, int, int]
|
||||
|
||||
@staticmethod
|
||||
def segment_checksum(bs: bytes, size: int):
|
||||
@@ -607,7 +594,6 @@ class WavDolbyMetadataReader:
|
||||
|
||||
return retval
|
||||
|
||||
|
||||
def __init__(self, dbmd_data):
|
||||
self.segment_list = []
|
||||
|
||||
@@ -616,12 +602,12 @@ class WavDolbyMetadataReader:
|
||||
v_vec = []
|
||||
for _ in range(4):
|
||||
b = h.read(1)
|
||||
v_vec.insert(0, unpack("B",b)[0])
|
||||
v_vec.insert(0, unpack("B", b)[0])
|
||||
|
||||
self.version = tuple(v_vec)
|
||||
|
||||
while True:
|
||||
stype= SegmentType(unpack("B", h.read(1))[0])
|
||||
stype = SegmentType(unpack("B", h.read(1))[0])
|
||||
if stype == SegmentType.EndMarker:
|
||||
break
|
||||
else:
|
||||
@@ -646,28 +632,28 @@ class WavDolbyMetadataReader:
|
||||
"""
|
||||
Every valid Dolby Digital Plus metadata segment in the file.
|
||||
"""
|
||||
return [x[2] for x in self.segment_list \
|
||||
return [x[2] for x in self.segment_list
|
||||
if x[0] == SegmentType.DolbyDigitalPlus and x[1]]
|
||||
|
||||
def dolby_atmos(self) -> List[DolbyAtmosMetadata]:
|
||||
"""
|
||||
Every valid Dolby Atmos metadata segment in the file.
|
||||
"""
|
||||
return [x[2] for x in self.segment_list \
|
||||
return [x[2] for x in self.segment_list
|
||||
if x[0] == SegmentType.DolbyAtmos and x[1]]
|
||||
|
||||
def dolby_atmos_supplemental(self) -> List[DolbyAtmosSupplementalMetadata]:
|
||||
"""
|
||||
Every valid Dolby Atmos Supplemental metadata segment in the file.
|
||||
"""
|
||||
return [x[2] for x in self.segment_list \
|
||||
return [x[2] for x in self.segment_list
|
||||
if x[0] == SegmentType.DolbyAtmosSupplemental and x[1]]
|
||||
|
||||
def to_dict(self) -> dict:
|
||||
|
||||
ddp = map(lambda x: asdict(x), self.dolby_digital_plus())
|
||||
atmos = map(lambda x: asdict(x), self.dolby_atmos())
|
||||
#atmos_sup = map(lambda x: asdict(x), self.dolby_atmos_supplemental())
|
||||
# atmos_sup = map(lambda x: asdict(x), self.dolby_atmos_supplemental())
|
||||
|
||||
return dict(dolby_digital_plus=list(ddp),
|
||||
dolby_atmos=list(atmos))
|
||||
|
||||
@@ -2,6 +2,7 @@ from .riff_parser import parse_chunk, ListChunkDescriptor
|
||||
|
||||
from typing import Optional
|
||||
|
||||
|
||||
class WavInfoChunkReader:
|
||||
|
||||
def __init__(self, f, encoding):
|
||||
@@ -18,42 +19,42 @@ class WavInfoChunkReader:
|
||||
if chunk.signature == b'INFO'), None)
|
||||
|
||||
#: 'ICOP' Copyright
|
||||
self.copyright : Optional[str] = self._get_field(f, b'ICOP')
|
||||
self.copyright: Optional[str] = self._get_field(f, b'ICOP')
|
||||
#: 'IPRD' Product
|
||||
self.product : Optional[str]= self._get_field(f, b'IPRD')
|
||||
self.album : Optional[str] = self.product
|
||||
self.product: Optional[str] = self._get_field(f, b'IPRD')
|
||||
self.album: Optional[str] = self.product
|
||||
#: 'IGNR' Genre
|
||||
self.genre : Optional[str] = self._get_field(f, b'IGNR')
|
||||
self.genre: Optional[str] = self._get_field(f, b'IGNR')
|
||||
#: 'ISBJ' Subject
|
||||
self.subject : Optional[str] = self._get_field(f, b'ISBJ')
|
||||
self.subject: Optional[str] = self._get_field(f, b'ISBJ')
|
||||
#: 'IART' Artist, composer, author
|
||||
self.artist : Optional[str] = self._get_field(f, b'IART')
|
||||
self.artist: Optional[str] = self._get_field(f, b'IART')
|
||||
#: 'ICMT' Comment
|
||||
self.comment : Optional[str] = self._get_field(f, b'ICMT')
|
||||
self.comment: Optional[str] = self._get_field(f, b'ICMT')
|
||||
#: 'ISFT' Software, encoding application
|
||||
self.software : Optional[str] = self._get_field(f, b'ISFT')
|
||||
self.software: Optional[str] = self._get_field(f, b'ISFT')
|
||||
#: 'ICRD' Created date
|
||||
self.created_date : Optional[str] = self._get_field(f, b'ICRD')
|
||||
self.created_date: Optional[str] = self._get_field(f, b'ICRD')
|
||||
#: 'IENG' Engineer
|
||||
self.engineer : Optional[str] = self._get_field(f, b'IENG')
|
||||
self.engineer: Optional[str] = self._get_field(f, b'IENG')
|
||||
#: 'ITCH' Technician
|
||||
self.technician : Optional[str] = self._get_field(f, b'ITCH')
|
||||
self.technician: Optional[str] = self._get_field(f, b'ITCH')
|
||||
#: 'IKEY' Keywords, keyword list
|
||||
self.keywords : Optional[str] = self._get_field(f, b'IKEY')
|
||||
self.keywords: Optional[str] = self._get_field(f, b'IKEY')
|
||||
#: 'INAM' Name, title
|
||||
self.title : Optional[str] = self._get_field(f, b'INAM')
|
||||
self.title: Optional[str] = self._get_field(f, b'INAM')
|
||||
#: 'ISRC' Source
|
||||
self.source : Optional[str] = self._get_field(f, b'ISRC')
|
||||
self.source: Optional[str] = self._get_field(f, b'ISRC')
|
||||
#: 'TAPE' Tape
|
||||
self.tape : Optional[str] = self._get_field(f, b'TAPE')
|
||||
self.tape: Optional[str] = self._get_field(f, b'TAPE')
|
||||
#: 'IARL' Archival Location
|
||||
self.archival_location : Optional[str] = self._get_field(f, b'IARL')
|
||||
self.archival_location: Optional[str] = self._get_field(f, b'IARL')
|
||||
#: 'ICSM' Commissioned
|
||||
self.commissioned : Optional[str] = self._get_field(f, b'ICMS')
|
||||
self.commissioned: Optional[str] = self._get_field(f, b'ICMS')
|
||||
|
||||
def _get_field(self, f, field_ident) -> Optional[str]:
|
||||
search = next(((chunk.start, chunk.length) \
|
||||
for chunk in self.info_chunk.children \
|
||||
search = next(((chunk.start, chunk.length)
|
||||
for chunk in self.info_chunk.children
|
||||
if chunk.ident == field_ident),
|
||||
None)
|
||||
|
||||
@@ -64,7 +65,7 @@ class WavInfoChunkReader:
|
||||
else:
|
||||
return None
|
||||
|
||||
def to_dict(self) -> dict: #FIXME should be asdict
|
||||
def to_dict(self) -> dict: # FIXME should be asdict
|
||||
"""
|
||||
A dictionary with all of the key/values read from the INFO scope.
|
||||
"""
|
||||
|
||||
@@ -12,6 +12,7 @@ class IXMLTrack(NamedTuple):
|
||||
name: str
|
||||
function: str
|
||||
|
||||
|
||||
class SteinbergMetadata:
|
||||
"""
|
||||
Vendor-specific Steinberg metadata.
|
||||
@@ -34,7 +35,7 @@ class SteinbergMetadata:
|
||||
CINE_71 = 27
|
||||
SDDS_70 = 24
|
||||
SDDS_71 = 26
|
||||
MUSIC_60 = 21 #??
|
||||
MUSIC_60 = 21 # ??
|
||||
MUSIC_61 = 23
|
||||
ATMOS_712 = 33
|
||||
ATMOS_504 = 35
|
||||
@@ -155,6 +156,7 @@ class WavIXMLFormat:
|
||||
"""
|
||||
iXML recorder metadata.
|
||||
"""
|
||||
|
||||
def __init__(self, xml):
|
||||
"""
|
||||
Parse iXML.
|
||||
@@ -163,7 +165,7 @@ class WavIXMLFormat:
|
||||
self.source = xml
|
||||
xml_bytes = io.BytesIO(xml)
|
||||
parser = ET.XMLParser(recover=True)
|
||||
self.parsed : ET.ElementTree = ET.parse(xml_bytes, parser=parser)
|
||||
self.parsed: ET.ElementTree = ET.parse(xml_bytes, parser=parser)
|
||||
|
||||
def _get_text_value(self, xpath) -> Optional[str]:
|
||||
e = self.parsed.find("./" + xpath)
|
||||
@@ -192,14 +194,11 @@ class WavIXMLFormat:
|
||||
for track in self.parsed.find("./TRACK_LIST").iter():
|
||||
if track.tag == 'TRACK':
|
||||
yield IXMLTrack(
|
||||
channel_index=
|
||||
track.xpath('string(CHANNEL_INDEX/text())'),
|
||||
interleave_index=
|
||||
track.xpath('string(INTERLEAVE_INDEX/text())'),
|
||||
name=
|
||||
track.xpath('string(NAME/text())'),
|
||||
function=
|
||||
track.xpath('string(FUNCTION/text())')
|
||||
channel_index=track.xpath('string(CHANNEL_INDEX/text())'),
|
||||
interleave_index=track.xpath(
|
||||
'string(INTERLEAVE_INDEX/text())'),
|
||||
name=track.xpath('string(NAME/text())'),
|
||||
function=track.xpath('string(FUNCTION/text())')
|
||||
)
|
||||
|
||||
@property
|
||||
@@ -260,4 +259,4 @@ class WavIXMLFormat:
|
||||
track_list=list(map(lambda x: x._asdict(), self.track_list)),
|
||||
project=self.project, scene=self.scene, take=self.take,
|
||||
tape=self.tape, family_uid=self.family_uid,
|
||||
family_name=self.family_name )
|
||||
family_name=self.family_name)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#-*- coding: utf-8 -*-
|
||||
# -*- coding: utf-8 -*-
|
||||
import struct
|
||||
import os
|
||||
from typing import Optional, Generator, Any, NamedTuple
|
||||
@@ -14,6 +14,8 @@ from .wave_dbmd_reader import WavDolbyMetadataReader
|
||||
from .wave_cues_reader import WavCuesReader
|
||||
|
||||
#: Calculated statistics about the audio data.
|
||||
|
||||
|
||||
class WavDataDescriptor(NamedTuple):
|
||||
byte_count: int
|
||||
frame_count: int
|
||||
@@ -28,6 +30,7 @@ class WavAudioFormat(NamedTuple):
|
||||
block_align: int
|
||||
bits_per_sample: int
|
||||
|
||||
|
||||
class WavInfoReader:
|
||||
"""
|
||||
Parse a WAV audio file for metadata.
|
||||
@@ -55,28 +58,28 @@ class WavInfoReader:
|
||||
self.bext_encoding = bext_encoding
|
||||
|
||||
#: Wave audio data format.
|
||||
self.fmt :Optional[WavAudioFormat] = None
|
||||
self.fmt: Optional[WavAudioFormat] = None
|
||||
|
||||
#: Statistics of the `data` section.
|
||||
self.data :Optional[WavDataDescriptor] = None
|
||||
self.data: Optional[WavDataDescriptor] = None
|
||||
|
||||
#: Broadcast-Wave metadata.
|
||||
self.bext :Optional[WavBextReader] = None
|
||||
self.bext: Optional[WavBextReader] = None
|
||||
|
||||
#: iXML metadata.
|
||||
self.ixml :Optional[WavIXMLFormat] = None
|
||||
self.ixml: Optional[WavIXMLFormat] = None
|
||||
|
||||
#: ADM Audio Definiton Model metadata.
|
||||
self.adm :Optional[WavADMReader]= None
|
||||
self.adm: Optional[WavADMReader] = None
|
||||
|
||||
#: Dolby bitstream metadata.
|
||||
self.dolby :Optional[WavDolbyMetadataReader] = None
|
||||
self.dolby: Optional[WavDolbyMetadataReader] = None
|
||||
|
||||
#: RIFF INFO metadata.
|
||||
self.info :Optional[WavInfoChunkReader]= None
|
||||
self.info: Optional[WavInfoChunkReader] = None
|
||||
|
||||
#: RIFF cues markers, labels, and notes.
|
||||
self.cues :Optional[WavCuesReader] = None
|
||||
self.cues: Optional[WavCuesReader] = None
|
||||
|
||||
if hasattr(f, 'read'):
|
||||
self.get_wav_info(f)
|
||||
@@ -112,7 +115,7 @@ class WavInfoReader:
|
||||
|
||||
def _find_chunk_data(self, ident, from_stream,
|
||||
default_none=False) -> Optional[bytes]:
|
||||
top_chunks = (chunk for chunk in self.main_list \
|
||||
top_chunks = (chunk for chunk in self.main_list
|
||||
if type(chunk) is ChunkDescriptor and chunk.ident == ident)
|
||||
|
||||
chunk_descriptor = next(top_chunks, None) \
|
||||
@@ -122,14 +125,14 @@ class WavInfoReader:
|
||||
if chunk_descriptor else None
|
||||
|
||||
def _find_list_chunk(self, signature) -> Optional[ListChunkDescriptor]:
|
||||
top_chunks = (chunk for chunk in self.main_list \
|
||||
if type(chunk) is ListChunkDescriptor and \
|
||||
top_chunks = (chunk for chunk in self.main_list
|
||||
if type(chunk) is ListChunkDescriptor and
|
||||
chunk.signature == signature)
|
||||
|
||||
return next(top_chunks, None)
|
||||
|
||||
def _describe_data(self):
|
||||
data_chunk = next(c for c in self.main_list \
|
||||
data_chunk = next(c for c in self.main_list
|
||||
if type(c) is ChunkDescriptor and c.ident == b'data')
|
||||
|
||||
assert isinstance(self.fmt, WavAudioFormat)
|
||||
@@ -155,7 +158,7 @@ class WavInfoReader:
|
||||
)
|
||||
|
||||
def _get_info(self, f, encoding):
|
||||
finder = (chunk.signature for chunk in self.main_list \
|
||||
finder = (chunk.signature for chunk in self.main_list
|
||||
if type(chunk) is ListChunkDescriptor)
|
||||
|
||||
if b'INFO' in finder:
|
||||
@@ -181,8 +184,8 @@ class WavInfoReader:
|
||||
return WavIXMLFormat(ixml_data.rstrip(b'\0')) if ixml_data else None
|
||||
|
||||
def _get_cue(self, f):
|
||||
cue = next((cue_chunk for cue_chunk in self.main_list if \
|
||||
type(cue_chunk) is ChunkDescriptor and \
|
||||
cue = next((cue_chunk for cue_chunk in self.main_list if
|
||||
type(cue_chunk) is ChunkDescriptor and
|
||||
cue_chunk.ident == b'cue '), None)
|
||||
|
||||
adtl = self._find_list_chunk(b'adtl')
|
||||
@@ -197,7 +200,8 @@ class WavInfoReader:
|
||||
return WavCuesReader.read_all(f, cue, labls, ltxts, notes,
|
||||
fallback_encoding=self.info_encoding)
|
||||
|
||||
def walk(self) -> Generator[str,str,Any]: #FIXME: this should probably be named "iter()"
|
||||
# FIXME: this should probably be named "iter()"
|
||||
def walk(self) -> Generator[str, str, Any]:
|
||||
"""
|
||||
Walk all of the available metadata fields.
|
||||
|
||||
@@ -216,7 +220,8 @@ class WavInfoReader:
|
||||
yield scope, field, attr.__getattribute__(field)
|
||||
|
||||
else:
|
||||
dict = self.__getattribute__(scope).to_dict() if self.__getattribute__(scope) else {}
|
||||
dict = self.__getattribute__(scope).to_dict(
|
||||
) if self.__getattribute__(scope) else {}
|
||||
for key in dict.keys():
|
||||
yield scope, key, dict[key]
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ def main():
|
||||
help='Search descriptions',
|
||||
metavar='DESC')
|
||||
|
||||
|
||||
(options, args) = parser.parse_args(sys.argv)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user