def decrypter(self, info_dict):
    _key_cache = {}

    def _get_key(url):
        if (url not in _key_cache):
            _key_cache[url] = self.ydl.urlopen(self._prepare_url(info_dict, url)).read()
        return _key_cache[url]

    def decrypt_fragment(fragment, frag_content):
        decrypt_info = fragment.get('decrypt_info')
        if ((not decrypt_info) or (decrypt_info['METHOD'] != 'AES-128')):
            return frag_content
        iv = (decrypt_info.get('IV') or compat_struct_pack('>8xq', fragment['media_sequence']))
        decrypt_info['KEY'] = (decrypt_info.get('KEY') or _get_key((info_dict.get('_decryption_key_url') or decrypt_info['URI'])))
        if self.params.get('test', False):
            return frag_content
        return unpad_pkcs7(aes_cbc_decrypt_bytes(frag_content, decrypt_info['KEY'], iv))
    return decrypt_fragment
def decrypter(self, info_dict):
    _key_cache = {}

    def _get_key(url):
        if (url not in _key_cache):
            _key_cache[url] = self.ydl.urlopen(self._prepare_url(info_dict, url)).read()
        return _key_cache[url]

    def decrypt_fragment(fragment, frag_content):
        decrypt_info = fragment.get('decrypt_info')
        if ((not decrypt_info) or (decrypt_info['METHOD'] != 'AES-128')):
            return frag_content
        iv = (decrypt_info.get('IV') or compat_struct_pack('>8xq', fragment['media_sequence']))
        decrypt_info['KEY'] = (decrypt_info.get('KEY') or _get_key((info_dict.get('_decryption_key_url') or decrypt_info['URI'])))
        if self.params.get('test', False):
            return frag_content
        return unpad_pkcs7(aes_cbc_decrypt_bytes(frag_content, decrypt_info['KEY'], iv))
    return decrypt_fragment