def __parse_integer(self, atom, data): values = [] for version, flags, data in self.__parse_data(atom, data): if version != 0: raise MP4MetadataValueError("unsupported version") if flags not in (AtomDataType.IMPLICIT, AtomDataType.INTEGER): raise MP4MetadataValueError("unsupported type") if len(data) == 1: value = cdata.int8(data) elif len(data) == 2: value = cdata.int16_be(data) elif len(data) == 3: value = cdata.int32_be(data + b"\x00") >> 8 elif len(data) == 4: value = cdata.int32_be(data) elif len(data) == 8: value = cdata.int64_be(data) else: raise MP4MetadataValueError("invalid value size %d" % len(data)) values.append(value) key = _name2key(atom.name) self.__add(key, values)
def __parse_integer(self, atom, data): values = [] for version, flags, data in self.__parse_data(atom, data): if version != 0: raise MP4MetadataValueError("unsupported version") if flags not in (AtomDataType.IMPLICIT, AtomDataType.INTEGER): raise MP4MetadataValueError("unsupported type") if len(data) == 1: value = cdata.int8(data) elif len(data) == 2: value = cdata.int16_be(data) elif len(data) == 3: value = cdata.int32_be(data + b"\x00") >> 8 elif len(data) == 4: value = cdata.int32_be(data) elif len(data) == 8: value = cdata.int64_be(data) else: raise MP4MetadataValueError( "invalid value size %d" % len(data)) values.append(value) key = _name2key(atom.name) self.__add(key, values)