Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return {}
# The parser tree: Each key is an atom name which is traversed if existing.
# Leaves of the parser tree are callables which receive the atom data.
# callables return {fieldname: value} which is updates the TinyTag.
META_DATA_TREE = {b'moov': {b'udta': {b'meta': {b'ilst': {
# see: http://atomicparsley.sourceforge.net/mpeg-4files.html
b'\xa9alb': {b'data': Parser.make_data_atom_parser('album')},
b'\xa9ART': {b'data': Parser.make_data_atom_parser('artist')},
b'aART': {b'data': Parser.make_data_atom_parser('albumartist')},
# b'cpil': {b'data': Parser.make_data_atom_parser('compilation')},
b'\xa9cmt': {b'data': Parser.make_data_atom_parser('comment')},
b'disk': {b'data': Parser.make_number_parser('disc', 'disc_total')},
b'\xa9wrt': {b'data': Parser.make_data_atom_parser('composer')},
b'\xa9day': {b'data': Parser.make_data_atom_parser('year')},
b'\xa9gen': {b'data': Parser.make_data_atom_parser('genre')},
b'gnre': {b'data': Parser.parse_id3v1_genre},
b'\xa9nam': {b'data': Parser.make_data_atom_parser('title')},
b'trkn': {b'data': Parser.make_number_parser('track', 'track_total')},
}}}}}
# see: https://developer.apple.com/library/mac/documentation/QuickTime/QTFF/QTFFChap3/qtff3.html
AUDIO_DATA_TREE = {
b'moov': {
b'mvhd': Parser.parse_mvhd,
b'trak': {b'mdia': {b"minf": {b"stbl": {b"stsd": {b'mp4a':
Parser.parse_audio_sample_entry
}}}}}
}
}
IMAGE_DATA_TREE = {b'moov': {b'udta': {b'meta': {b'ilst': {
duration = struct.unpack('>q', walker.read(8))[0]
return {'duration': float(duration) / time_scale}
@classmethod
def debug_atom(cls, data):
stderr(data) # use this function to inspect atoms in an atom tree
return {}
# The parser tree: Each key is an atom name which is traversed if existing.
# Leaves of the parser tree are callables which receive the atom data.
# callables return {fieldname: value} which is updates the TinyTag.
META_DATA_TREE = {b'moov': {b'udta': {b'meta': {b'ilst': {
# see: http://atomicparsley.sourceforge.net/mpeg-4files.html
b'\xa9alb': {b'data': Parser.make_data_atom_parser('album')},
b'\xa9ART': {b'data': Parser.make_data_atom_parser('artist')},
b'aART': {b'data': Parser.make_data_atom_parser('albumartist')},
# b'cpil': {b'data': Parser.make_data_atom_parser('compilation')},
b'\xa9cmt': {b'data': Parser.make_data_atom_parser('comment')},
b'disk': {b'data': Parser.make_number_parser('disc', 'disc_total')},
b'\xa9wrt': {b'data': Parser.make_data_atom_parser('composer')},
b'\xa9day': {b'data': Parser.make_data_atom_parser('year')},
b'\xa9gen': {b'data': Parser.make_data_atom_parser('genre')},
b'gnre': {b'data': Parser.parse_id3v1_genre},
b'\xa9nam': {b'data': Parser.make_data_atom_parser('title')},
b'trkn': {b'data': Parser.make_number_parser('track', 'track_total')},
}}}}}
# see: https://developer.apple.com/library/mac/documentation/QuickTime/QTFF/QTFFChap3/qtff3.html
AUDIO_DATA_TREE = {
b'moov': {
b'mvhd': Parser.parse_mvhd,
b'trak': {b'mdia': {b"minf": {b"stbl": {b"stsd": {b'mp4a':
@classmethod
def debug_atom(cls, data):
stderr(data) # use this function to inspect atoms in an atom tree
return {}
# The parser tree: Each key is an atom name which is traversed if existing.
# Leaves of the parser tree are callables which receive the atom data.
# callables return {fieldname: value} which is updates the TinyTag.
META_DATA_TREE = {b'moov': {b'udta': {b'meta': {b'ilst': {
# see: http://atomicparsley.sourceforge.net/mpeg-4files.html
b'\xa9alb': {b'data': Parser.make_data_atom_parser('album')},
b'\xa9ART': {b'data': Parser.make_data_atom_parser('artist')},
b'aART': {b'data': Parser.make_data_atom_parser('albumartist')},
# b'cpil': {b'data': Parser.make_data_atom_parser('compilation')},
b'\xa9cmt': {b'data': Parser.make_data_atom_parser('comment')},
b'disk': {b'data': Parser.make_number_parser('disc', 'disc_total')},
b'\xa9wrt': {b'data': Parser.make_data_atom_parser('composer')},
b'\xa9day': {b'data': Parser.make_data_atom_parser('year')},
b'\xa9gen': {b'data': Parser.make_data_atom_parser('genre')},
b'gnre': {b'data': Parser.parse_id3v1_genre},
b'\xa9nam': {b'data': Parser.make_data_atom_parser('title')},
b'trkn': {b'data': Parser.make_number_parser('track', 'track_total')},
}}}}}
# see: https://developer.apple.com/library/mac/documentation/QuickTime/QTFF/QTFFChap3/qtff3.html
AUDIO_DATA_TREE = {
b'moov': {
b'mvhd': Parser.parse_mvhd,
b'trak': {b'mdia': {b"minf": {b"stbl": {b"stsd": {b'mp4a':
Parser.parse_audio_sample_entry
}}}}}
b'\xa9nam': {b'data': Parser.make_data_atom_parser('title')},
b'trkn': {b'data': Parser.make_number_parser('track', 'track_total')},
}}}}}
# see: https://developer.apple.com/library/mac/documentation/QuickTime/QTFF/QTFFChap3/qtff3.html
AUDIO_DATA_TREE = {
b'moov': {
b'mvhd': Parser.parse_mvhd,
b'trak': {b'mdia': {b"minf": {b"stbl": {b"stsd": {b'mp4a':
Parser.parse_audio_sample_entry
}}}}}
}
}
IMAGE_DATA_TREE = {b'moov': {b'udta': {b'meta': {b'ilst': {
b'covr': {b'data': Parser.make_data_atom_parser('_image_data')},
}}}}}
VERSIONED_ATOMS = {b'meta', b'stsd'} # those have an extra 4 byte header
FLAGGED_ATOMS = {b'stsd'} # these also have an extra 4 byte header
def _determine_duration(self, fh):
self._traverse_atoms(fh, path=self.AUDIO_DATA_TREE)
def _parse_tag(self, fh):
self._traverse_atoms(fh, path=self.META_DATA_TREE)
if self._load_image: # A bit inefficient, we rewind the file
self._filehandler.seek(0) # to parse it again for the image
self._traverse_atoms(fh, path=self.IMAGE_DATA_TREE)
def _traverse_atoms(self, fh, path, stop_pos=None, curr_path=None):
header_size = 8
stderr(data) # use this function to inspect atoms in an atom tree
return {}
# The parser tree: Each key is an atom name which is traversed if existing.
# Leaves of the parser tree are callables which receive the atom data.
# callables return {fieldname: value} which is updates the TinyTag.
META_DATA_TREE = {b'moov': {b'udta': {b'meta': {b'ilst': {
# see: http://atomicparsley.sourceforge.net/mpeg-4files.html
b'\xa9alb': {b'data': Parser.make_data_atom_parser('album')},
b'\xa9ART': {b'data': Parser.make_data_atom_parser('artist')},
b'aART': {b'data': Parser.make_data_atom_parser('albumartist')},
# b'cpil': {b'data': Parser.make_data_atom_parser('compilation')},
b'\xa9cmt': {b'data': Parser.make_data_atom_parser('comment')},
b'disk': {b'data': Parser.make_number_parser('disc', 'disc_total')},
b'\xa9wrt': {b'data': Parser.make_data_atom_parser('composer')},
b'\xa9day': {b'data': Parser.make_data_atom_parser('year')},
b'\xa9gen': {b'data': Parser.make_data_atom_parser('genre')},
b'gnre': {b'data': Parser.parse_id3v1_genre},
b'\xa9nam': {b'data': Parser.make_data_atom_parser('title')},
b'trkn': {b'data': Parser.make_number_parser('track', 'track_total')},
}}}}}
# see: https://developer.apple.com/library/mac/documentation/QuickTime/QTFF/QTFFChap3/qtff3.html
AUDIO_DATA_TREE = {
b'moov': {
b'mvhd': Parser.parse_mvhd,
b'trak': {b'mdia': {b"minf": {b"stbl": {b"stsd": {b'mp4a':
Parser.parse_audio_sample_entry
}}}}}
}
}
walker.seek(16, os.SEEK_CUR) # jump over create & mod times
time_scale = struct.unpack('>I', walker.read(4))[0]
duration = struct.unpack('>q', walker.read(8))[0]
return {'duration': float(duration) / time_scale}
@classmethod
def debug_atom(cls, data):
stderr(data) # use this function to inspect atoms in an atom tree
return {}
# The parser tree: Each key is an atom name which is traversed if existing.
# Leaves of the parser tree are callables which receive the atom data.
# callables return {fieldname: value} which is updates the TinyTag.
META_DATA_TREE = {b'moov': {b'udta': {b'meta': {b'ilst': {
# see: http://atomicparsley.sourceforge.net/mpeg-4files.html
b'\xa9alb': {b'data': Parser.make_data_atom_parser('album')},
b'\xa9ART': {b'data': Parser.make_data_atom_parser('artist')},
b'aART': {b'data': Parser.make_data_atom_parser('albumartist')},
# b'cpil': {b'data': Parser.make_data_atom_parser('compilation')},
b'\xa9cmt': {b'data': Parser.make_data_atom_parser('comment')},
b'disk': {b'data': Parser.make_number_parser('disc', 'disc_total')},
b'\xa9wrt': {b'data': Parser.make_data_atom_parser('composer')},
b'\xa9day': {b'data': Parser.make_data_atom_parser('year')},
b'\xa9gen': {b'data': Parser.make_data_atom_parser('genre')},
b'gnre': {b'data': Parser.parse_id3v1_genre},
b'\xa9nam': {b'data': Parser.make_data_atom_parser('title')},
b'trkn': {b'data': Parser.make_number_parser('track', 'track_total')},
}}}}}
# see: https://developer.apple.com/library/mac/documentation/QuickTime/QTFF/QTFFChap3/qtff3.html
AUDIO_DATA_TREE = {
b'moov': {
# The parser tree: Each key is an atom name which is traversed if existing.
# Leaves of the parser tree are callables which receive the atom data.
# callables return {fieldname: value} which is updates the TinyTag.
META_DATA_TREE = {b'moov': {b'udta': {b'meta': {b'ilst': {
# see: http://atomicparsley.sourceforge.net/mpeg-4files.html
b'\xa9alb': {b'data': Parser.make_data_atom_parser('album')},
b'\xa9ART': {b'data': Parser.make_data_atom_parser('artist')},
b'aART': {b'data': Parser.make_data_atom_parser('albumartist')},
# b'cpil': {b'data': Parser.make_data_atom_parser('compilation')},
b'\xa9cmt': {b'data': Parser.make_data_atom_parser('comment')},
b'disk': {b'data': Parser.make_number_parser('disc', 'disc_total')},
b'\xa9wrt': {b'data': Parser.make_data_atom_parser('composer')},
b'\xa9day': {b'data': Parser.make_data_atom_parser('year')},
b'\xa9gen': {b'data': Parser.make_data_atom_parser('genre')},
b'gnre': {b'data': Parser.parse_id3v1_genre},
b'\xa9nam': {b'data': Parser.make_data_atom_parser('title')},
b'trkn': {b'data': Parser.make_number_parser('track', 'track_total')},
}}}}}
# see: https://developer.apple.com/library/mac/documentation/QuickTime/QTFF/QTFFChap3/qtff3.html
AUDIO_DATA_TREE = {
b'moov': {
b'mvhd': Parser.parse_mvhd,
b'trak': {b'mdia': {b"minf": {b"stbl": {b"stsd": {b'mp4a':
Parser.parse_audio_sample_entry
}}}}}
}
}
IMAGE_DATA_TREE = {b'moov': {b'udta': {b'meta': {b'ilst': {
b'covr': {b'data': Parser.make_data_atom_parser('_image_data')},
}}}}}
def debug_atom(cls, data):
stderr(data) # use this function to inspect atoms in an atom tree
return {}
# The parser tree: Each key is an atom name which is traversed if existing.
# Leaves of the parser tree are callables which receive the atom data.
# callables return {fieldname: value} which is updates the TinyTag.
META_DATA_TREE = {b'moov': {b'udta': {b'meta': {b'ilst': {
# see: http://atomicparsley.sourceforge.net/mpeg-4files.html
b'\xa9alb': {b'data': Parser.make_data_atom_parser('album')},
b'\xa9ART': {b'data': Parser.make_data_atom_parser('artist')},
b'aART': {b'data': Parser.make_data_atom_parser('albumartist')},
# b'cpil': {b'data': Parser.make_data_atom_parser('compilation')},
b'\xa9cmt': {b'data': Parser.make_data_atom_parser('comment')},
b'disk': {b'data': Parser.make_number_parser('disc', 'disc_total')},
b'\xa9wrt': {b'data': Parser.make_data_atom_parser('composer')},
b'\xa9day': {b'data': Parser.make_data_atom_parser('year')},
b'\xa9gen': {b'data': Parser.make_data_atom_parser('genre')},
b'gnre': {b'data': Parser.parse_id3v1_genre},
b'\xa9nam': {b'data': Parser.make_data_atom_parser('title')},
b'trkn': {b'data': Parser.make_number_parser('track', 'track_total')},
}}}}}
# see: https://developer.apple.com/library/mac/documentation/QuickTime/QTFF/QTFFChap3/qtff3.html
AUDIO_DATA_TREE = {
b'moov': {
b'mvhd': Parser.parse_mvhd,
b'trak': {b'mdia': {b"minf": {b"stbl": {b"stsd": {b'mp4a':
Parser.parse_audio_sample_entry
}}}}}
}
}