mirror of
https://github.com/iluvcapra/wavinfo.git
synced 2026-01-01 17:30:41 +00:00
UMID Implementation
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
|
||||
from .riff_parser import parse_chunk, ListChunkDescriptor
|
||||
|
||||
|
||||
class WavInfoChunkReader:
|
||||
|
||||
def __init__(self, f, encoding):
|
||||
@@ -9,53 +9,48 @@ class WavInfoChunkReader:
|
||||
f.seek(0)
|
||||
parsed_chunks = parse_chunk(f)
|
||||
|
||||
list_chunks = [chunk for chunk in parsed_chunks.children \
|
||||
if type(chunk) is ListChunkDescriptor]
|
||||
list_chunks = [chunk for chunk in parsed_chunks.children if type(chunk) is ListChunkDescriptor]
|
||||
|
||||
self.info_chunk = next((chunk for chunk in list_chunks if chunk.signature == b'INFO'), None)
|
||||
|
||||
self.info_chunk = next((chunk for chunk in list_chunks \
|
||||
if chunk.signature == b'INFO'), None)
|
||||
|
||||
#: 'ICOP' Copyright
|
||||
self.copyright = self._get_field(f,b'ICOP')
|
||||
self.copyright = self._get_field(f, b'ICOP')
|
||||
#: 'IPRD' Product
|
||||
self.product = self._get_field(f,b'IPRD')
|
||||
self.product = self._get_field(f, b'IPRD')
|
||||
#: 'IGNR' Genre
|
||||
self.genre = self._get_field(f,b'IGNR')
|
||||
self.genre = self._get_field(f, b'IGNR')
|
||||
#: 'ISBJ' Supject
|
||||
self.subject = self._get_field(f,b'ISBJ')
|
||||
self.subject = self._get_field(f, b'ISBJ')
|
||||
#: 'IART' Artist, composer, author
|
||||
self.artist = self._get_field(f,b'IART')
|
||||
self.artist = self._get_field(f, b'IART')
|
||||
#: 'ICMT' Comment
|
||||
self.comment = self._get_field(f,b'ICMT')
|
||||
self.comment = self._get_field(f, b'ICMT')
|
||||
#: 'ISFT' Software, encoding application
|
||||
self.software = self._get_field(f,b'ISFT')
|
||||
self.software = self._get_field(f, b'ISFT')
|
||||
#: 'ICRD' Created date
|
||||
self.created_date = self._get_field(f,b'ICRD')
|
||||
self.created_date = self._get_field(f, b'ICRD')
|
||||
#: 'IENG' Engineer
|
||||
self.engineer = self._get_field(f,b'IENG')
|
||||
self.engineer = self._get_field(f, b'IENG')
|
||||
#: 'ITCH' Technician
|
||||
self.technician = self._get_field(f,b'ITCH')
|
||||
self.technician = self._get_field(f, b'ITCH')
|
||||
#: 'IKEY' Keywords, keyword list
|
||||
self.keywords = self._get_field(f,b'IKEY')
|
||||
self.keywords = self._get_field(f, b'IKEY')
|
||||
#: 'INAM' Name, title
|
||||
self.title = self._get_field(f,b'INAM')
|
||||
self.title = self._get_field(f, b'INAM')
|
||||
#: 'ISRC' Source
|
||||
self.source = self._get_field(f,b'ISRC')
|
||||
self.source = self._get_field(f, b'ISRC')
|
||||
#: 'TAPE' Tape
|
||||
self.tape = self._get_field(f,b'TAPE')
|
||||
self.tape = self._get_field(f, b'TAPE')
|
||||
#: 'IARL' Archival Location
|
||||
self.archival_location = self._get_field(f,b'IARL')
|
||||
self.archival_location = self._get_field(f, b'IARL')
|
||||
#: 'ISFT' Software
|
||||
self.software = self._get_field(f,b'ISFT')
|
||||
self.software = self._get_field(f, b'ISFT')
|
||||
#: 'ICSM' Commissioned
|
||||
self.commissioned = self._get_field(f,b'ICMS')
|
||||
|
||||
|
||||
self.commissioned = self._get_field(f, b'ICMS')
|
||||
|
||||
def _get_field(self, f, field_ident):
|
||||
|
||||
search = next( ( (chunk.start, chunk.length) for chunk in self.info_chunk.children \
|
||||
if chunk.ident == field_ident ), None)
|
||||
search = next(((chunk.start, chunk.length) for chunk in self.info_chunk.children if chunk.ident == field_ident),
|
||||
None)
|
||||
|
||||
if search is not None:
|
||||
f.seek(search[0])
|
||||
@@ -64,32 +59,24 @@ class WavInfoChunkReader:
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def to_dict(self):
|
||||
"""
|
||||
A dictionary with all of the key/values read from the INFO scope.
|
||||
"""
|
||||
return {'copyright': self.copyright,
|
||||
'product': self.product,
|
||||
'genre': self.genre,
|
||||
'artist': self.artist,
|
||||
'comment': self.comment,
|
||||
return {'copyright': self.copyright,
|
||||
'product': self.product,
|
||||
'genre': self.genre,
|
||||
'artist': self.artist,
|
||||
'comment': self.comment,
|
||||
'software': self.software,
|
||||
'created_date': self.created_date,
|
||||
'engineer': self.engineer,
|
||||
'keywords': self.keywords,
|
||||
'title': self.title,
|
||||
'source': self.source,
|
||||
'tape': self.tape,
|
||||
'title': self.title,
|
||||
'source': self.source,
|
||||
'tape': self.tape,
|
||||
'commissioned': self.commissioned,
|
||||
'software': self.software,
|
||||
'archival_location':self.archival_location,
|
||||
'subject': self.subject,
|
||||
'technician':self.technician
|
||||
'archival_location': self.archival_location,
|
||||
'subject': self.subject,
|
||||
'technician': self.technician
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user