

def write(self, sequence, res, chunk_size=8192):
    if (sequence.segment.key and (sequence.segment.key.method != 'NONE')):
        try:
            decryptor = self.create_decryptor(sequence.segment.key, sequence.num)
        except StreamError as err:
            self.logger.error('Failed to create decryptor: {0}', err)
            self.close()
            return
        garbage_len = (len(res.content) % 16)
        if garbage_len:
            self.logger.debug('Cutting off {0} bytes of garbage before decrypting', garbage_len)
            content = decryptor.decrypt(res.content[:(- garbage_len)])
        else:
            content = decryptor.decrypt(res.content)
    else:
        content = res.content
    self.reader.buffer.write(content)
    self.logger.debug('Download of segment {0} complete', sequence.num)

dataset/ETHPy150Open chrippa/livestreamer/src/livestreamer/stream/hls.py HLSStreamWriter.write/original