示例#1
0
    def __next__(self):
        key = self.__read(self.key_length)
        # TODO : HOTFIX for some videos, make better
        # in some videos the header not follow the correct pattern
        # Sample key: b'\xdc\x00\x00\x06\x0e+4\x02\x0b\x01\x01\x0e\x01\x03\x01\x01'
        if (key.find(b'\x00\x00\x06\x0e+4\x02\x0b\x01\x01\x0e\x01\x03\x01\x01') > 0):
            key = b'\x06\x0e+4\x02\x0b\x01\x01\x0e\x01\x03\x01\x01\x00\x00\x00'
            byte_length = bytes_to_int(self.__read(4))
        else:
            byte_length = bytes_to_int(self.__read(1))

        if byte_length < 128:
            # BER Short Form
            length = byte_length
        else:
            # BER Long Form
            length = bytes_to_int(self.__read(byte_length - 128))

#         try:
#             value = self.__read(length)
#         except OverflowError:
#             value = self.__read(0)

        value = self.__read(length)

        return key, value
示例#2
0
    def __next__(self):
        key = self.__read(self.key_length)

        byte_length = bytes_to_int(self.__read(1))

        if byte_length < 128:
            # BER Short Form
            length = byte_length
        else:
            # BER Long Form
            length = bytes_to_int(self.__read(byte_length - 128))

        value = self.__read(length)

        return key, value
示例#3
0
    def __next__(self):
        key = self.__read(self.key_length)

        # if (key.find(b'\x00\x00\x06\x0e+4\x02\x0b\x01\x01\x0e\x01\x03\x01\x01') > 0):
        #     key = b'\x06\x0e+4\x02\x0b\x01\x01\x0e\x01\x03\x01\x01\x00\x00\x00'
        if (key.find(b'\x0b\x01\x01\x0e\x01\x03\x01\x01') > 0):
            key = b'\x0b\x01\x01\x0e\x01\x03\x01\x01\x00\x00\x00'
            byte_length = bytes_to_int(self.__read(4))
        else:
            byte_length = bytes_to_int(self.__read(1))

        if byte_length < 128:
            # BER Short Form
            length = byte_length
        else:
            # BER Long Form
            length = bytes_to_int(self.__read(byte_length - 128))

        value = self.__read(length)

        return key, value
示例#4
0
 def __init__(self, value):
     try:
         self.value = bytes_to_int(value)
     except TypeError:
         self.value = value