def metadata(self) -> Dict[mi.MetadataField, str]: mwm = self.mwm if mwm.metadata_offsets is None or self._index not in mwm.metadata_offsets: return {} old_pos = mwm.file.tell() new_pos = mwm.get_tag("meta").offset + mwm.metadata_offsets[self._index] mwm.file.seek(new_pos) metadata = {} if mwm.version().format >= 8: sz = read_varuint(mwm.file) for _ in range(sz): t = read_varuint(mwm.file) field = mi.MetadataField(t) metadata[field] = read_string(mwm.file) else: while True: t = read_uint(mwm.file, 1) is_last = t & 0x80 > 0 t = t & 0x7F l = read_uint(mwm.file, 1) field = mi.MetadataField(t) metadata[field] = mwm.file.read(l).decode("utf-8") if is_last: break mwm.file.seek(old_pos) return metadata
def metadata(self) -> Dict[mi.MetadataField, str]: m = self.ft.metadata() return {mi.MetadataField(int(k)): v for k, v in m.items()}