Python base64.standard_b64decode() Examples
The following are 30 code examples for showing how to use base64.standard_b64decode(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.
You may check out the related API usage on the sidebar.
You may also want to check out all available functions/classes of the module
base64
, or try the search function
.
Example 1
Project: warrant Author: capless File: aws_srp.py License: Apache License 2.0 | 6 votes |
def process_challenge(self, challenge_parameters): user_id_for_srp = challenge_parameters['USER_ID_FOR_SRP'] salt_hex = challenge_parameters['SALT'] srp_b_hex = challenge_parameters['SRP_B'] secret_block_b64 = challenge_parameters['SECRET_BLOCK'] # re strips leading zero from a day number (required by AWS Cognito) timestamp = re.sub(r" 0(\d) ", r" \1 ", datetime.datetime.utcnow().strftime("%a %b %d %H:%M:%S UTC %Y")) hkdf = self.get_password_authentication_key(user_id_for_srp, self.password, hex_to_long(srp_b_hex), salt_hex) secret_block_bytes = base64.standard_b64decode(secret_block_b64) msg = bytearray(self.pool_id.split('_')[1], 'utf-8') + bytearray(user_id_for_srp, 'utf-8') + \ bytearray(secret_block_bytes) + bytearray(timestamp, 'utf-8') hmac_obj = hmac.new(hkdf, msg, digestmod=hashlib.sha256) signature_string = base64.standard_b64encode(hmac_obj.digest()) response = {'TIMESTAMP': timestamp, 'USERNAME': user_id_for_srp, 'PASSWORD_CLAIM_SECRET_BLOCK': secret_block_b64, 'PASSWORD_CLAIM_SIGNATURE': signature_string.decode('utf-8')} if self.client_secret is not None: response.update({ "SECRET_HASH": self.get_secret_hash(self.username, self.client_id, self.client_secret)}) return response
Example 2
Project: insightconnect-plugins Author: rapid7 File: action.py License: MIT License | 6 votes |
def run(self, params={}): try: data = params.get(Input.BASE64) errors = params.get(Input.ERRORS) result = base64.standard_b64decode(data) if errors in ["replace", "ignore"]: return {Output.DATA: result.decode('utf-8', errors=errors)} else: return {Output.DATA: result.decode('utf-8')} except Exception as e: self.logger.error("An error has occurred while decoding ", e) raise PluginException( cause="Failed to decode because valid base64 input was not provided.", assistance='If you would like continue to attempt to decode the input try setting the value of the error field to ignore errors or to replace the characters.', data=e )
Example 3
Project: ironpython2 Author: IronLanguages File: test_base64.py License: Apache License 2.0 | 6 votes |
def test_b64decode_invalid_chars(self): # issue 1466065: Test some invalid characters. tests = ((b'%3d==', b'\xdd'), (b'$3d==', b'\xdd'), (b'[==', b''), (b'YW]3=', b'am'), (b'3{d==', b'\xdd'), (b'3d}==', b'\xdd'), (b'@@', b''), (b'!', b''), (b'YWJj\nYWI=', b'abcab')) for bstr, res in tests: self.assertEqual(base64.b64decode(bstr), res) self.assertEqual(base64.standard_b64decode(bstr), res) self.assertEqual(base64.urlsafe_b64decode(bstr), res) # Normal alphabet characters not discarded when alternative given res = b'\xFB\xEF\xBE\xFF\xFF\xFF' self.assertEqual(base64.b64decode(b'++[[//]]', b'[]'), res) self.assertEqual(base64.urlsafe_b64decode(b'++--//__'), res)
Example 4
Project: plugin.video.netflix Author: CastagnaIT File: http_server.py License: MIT License | 6 votes |
def do_POST(self): """Loads the licence for the requested resource""" try: url_parse = urlparse(self.path) common.debug('Handling HTTP POST IPC call to {}', url_parse.path) if '/license' not in url_parse: self.send_response(404) self.end_headers() return length = int(self.headers.get('content-length', 0)) data = self.rfile.read(length).decode('utf-8').split('!') b64license = self.server.msl_handler.get_license( challenge=data[0], sid=base64.standard_b64decode(data[1]).decode('utf-8')) self.send_response(200) self.end_headers() self.wfile.write(base64.standard_b64decode(b64license)) except Exception as exc: import traceback common.error(g.py2_decode(traceback.format_exc(), 'latin-1')) self.send_response(500 if isinstance(exc, MSLError) else 400) self.end_headers()
Example 5
Project: kubernetes_asyncio Author: tomplus File: kube_config.py License: Apache License 2.0 | 6 votes |
def as_file(self): """If obj[%data_key_name] exists, return name of a file with base64 decoded obj[%data_key_name] content otherwise obj[%file_key_name].""" use_data_if_no_file = not self._file and self._data if use_data_if_no_file: if self._base64_file_content: if isinstance(self._data, str): content = self._data.encode() else: content = self._data self._file = _create_temp_file_with_content( base64.standard_b64decode(content)) else: self._file = _create_temp_file_with_content(self._data) if self._file and not os.path.isfile(self._file): raise ConfigException("File does not exists: %s" % self._file) return self._file
Example 6
Project: n6 Author: CERT-Polska File: fields.py License: GNU Affero General Public License v3.0 | 6 votes |
def _urlsafe_b64decode(self, value): value = value.rstrip('\r\n') # some encoders like to append a newline... try: # `base64.urlsafe_b64decode()` just ignores illegal # characters *but* we want to be *more strict* if not self._URLSAFE_B64_VALID_CHARACTERS.issuperset(value): raise ValueError # `base64.urlsafe_b64decode()` (contrary to `base64.standard_b64decode()`) # does *not* accept unicode strings (even not pure-ASCII ones) :-/ value = string_as_bytes(value) value = base64.urlsafe_b64decode(value) except (ValueError, TypeError): # (TypeError is raised on incorrect Base64 padding) raise FieldValueError(public_message=( '"{}" is not a valid URL-safe-Base64-encoded string ' '[see: RFC 4648, section 5]'.format(ascii_str(value)))) return value
Example 7
Project: dcos-kafka-service Author: mesosphere File: release_builder.py License: Apache License 2.0 | 6 votes |
def _update_marathon_json(self, package_json): """Updates the marathon.json definition to contain the desired name and version strings. """ # note: the file isn't valid JSON, so we edit the raw content instead marathon_encoded = package_json.get("marathon", {}).get("v2AppMustacheTemplate") orig_marathon_lines = base64.standard_b64decode(marathon_encoded).decode().split("\n") marathon_lines = [] for line in orig_marathon_lines: name_match = re.match(r'^ *"PACKAGE_NAME": ?"(.*)",?$', line.rstrip("\n")) version_match = re.match(r'^ *"PACKAGE_VERSION": ?"(.*)",?$', line.rstrip("\n")) if name_match: line = line.replace(name_match.group(1), self._pkg_name) elif version_match: line = line.replace(version_match.group(1), self._pkg_version) marathon_lines.append(line) log.info("Updated marathon.json.mustache:") log.info("\n".join(difflib.unified_diff(orig_marathon_lines, marathon_lines, lineterm=""))) # Update parent package object with changes: package_json["marathon"]["v2AppMustacheTemplate"] = base64.standard_b64encode( "\n".join(marathon_lines).encode("utf-8") ).decode()
Example 8
Project: rethinkdb-python Author: rethinkdb File: handshake.py License: Apache License 2.0 | 6 votes |
def _read_auth_response(self, response): """ Read the authentication request's response sent by the database and validate the server signature which was returned. :param response: Response from the database :raises: ReqlDriverError | ReqlAuthError :return: None """ json_response = self._decode_json_response(response, with_utf8=True) ( first_client_message, authentication, ) = self._get_authentication_and_first_client_message(json_response) server_signature = base64.standard_b64decode(authentication[b"v"]) if not self._compare_digest(server_signature, self._server_signature): raise ReqlAuthError("Invalid server signature", self._host, self._port) self._next_state()
Example 9
Project: kitty Author: kovidgoyal File: send_text.py License: GNU General Public License v3.0 | 6 votes |
def response_from_kitty(self, boss: Boss, window: Optional[Window], payload_get: PayloadGetType) -> ResponseType: windows = [boss.active_window] match = payload_get('match') if match: windows = list(boss.match_windows(match)) mt = payload_get('match_tab') if mt: windows = [] tabs = tuple(boss.match_tabs(mt)) if not tabs: raise MatchError(payload_get('match_tab'), 'tabs') for tab in tabs: windows += tuple(tab) encoding, _, q = payload_get('data').partition(':') if encoding == 'text': data = q.encode('utf-8') elif encoding == 'base64': data = base64.standard_b64decode(q) else: raise TypeError(f'Invalid encoding for send-text data: {encoding}') for window in windows: if window is not None: window.write_to_child(data)
Example 10
Project: dl_coursera Author: feng-lei File: Crawler.py License: MIT License | 6 votes |
def _login(sess, cookies_file=None, cookies_base64=None): if cookies_file is None: if cookies_base64 is None: cookies_base64 = os.environ.get('DL_COURSERA_COOKIES_BASE64') assert cookies_base64 cookies = base64.standard_b64decode(cookies_base64) with TmpFile() as tmpfile: with open(tmpfile, 'wb') as ofs: ofs.write(cookies) cj = MozillaCookieJar() cj.load(tmpfile) else: cj = MozillaCookieJar() cj.load(cookies_file) sess.cookies.update(cj)
Example 11
Project: collection Author: skywind3000 File: cfs.py License: MIT License | 6 votes |
def sign_extract(signature): if not signature: return None, None, None try: text = base64.standard_b64decode(signature) except: return None, None, None part = text.split(':') if len(part) != 3: return None, None, None user = part[0].strip('\r\n\t ') try: ts = long(part[1]) except: return None, None, None verify = part[2].strip('\r\n\t ').lower() return user, ts, verify # 检查文件名
Example 12
Project: AIL-framework Author: CIRCL File: Screenshot.py License: GNU Affero General Public License v3.0 | 6 votes |
def save_crawled_screeshot(b64_screenshot, max_size, f_save=False): screenshot_size = (len(b64_screenshot)*3) /4 if screenshot_size < max_size or f_save: image_content = base64.standard_b64decode(b64_screenshot.encode()) sha256_string = sha256(image_content).hexdigest() filepath = get_screenshot_filepath(sha256_string) if os.path.isfile(filepath): #print('File already exist') return sha256_string # create dir dirname = os.path.dirname(filepath) if not os.path.exists(dirname): os.makedirs(dirname) with open(filepath, 'wb') as f: f.write(image_content) return sha256_string return False
Example 13
Project: azure-cosmos-python Author: Azure File: base.py License: MIT License | 6 votes |
def IsValidBase64String(string_to_validate): """Verifies if a string is a valid Base64 encoded string, after replacing '-' with '/' :param string string_to_validate: String to validate. :return: Whether given string is a valid base64 string or not. :rtype: str """ # '-' is not supported char for decoding in Python(same as C# and Java) which has similar logic while parsing ResourceID generated by backend try: buffer = base64.standard_b64decode(string_to_validate.replace('-', '/')) if len(buffer) != 4: return False except Exception as e: if six.PY2: e = e.message if type(e) == binascii.Error: return False else: raise e return True
Example 14
Project: ops-cli Author: adobe File: kube_config.py License: Apache License 2.0 | 6 votes |
def as_file(self): """If obj[%data_key_name] exists, return name of a file with base64 decoded obj[%data_key_name] content otherwise obj[%file_key_name].""" use_data_if_no_file = not self._file and self._data if use_data_if_no_file: if self._base64_file_content: if isinstance(self._data, str): content = self._data.encode() else: content = self._data self._file = _create_temp_file_with_content( base64.standard_b64decode(content)) else: self._file = _create_temp_file_with_content(self._data) if self._file and not os.path.isfile(self._file): raise ConfigException("File does not exists: %s" % self._file) return self._file
Example 15
Project: openbrokerapi Author: eruvanos File: request_filter.py License: MIT License | 6 votes |
def check_originating_identity(): """ Check and decode the "X-Broker-API-Originating-Identity" header https://github.com/openservicebrokerapi/servicebroker/blob/v2.13/spec.md#originating-identity """ from flask import request, json if "X-Broker-API-Originating-Identity" in request.headers: try: platform, value = request.headers["X-Broker-API-Originating-Identity"].split(None, 1) request.originating_identity = { 'platform': platform, 'value': json.loads(base64.standard_b64decode(value)) } except ValueError as e: return to_json_response(ErrorResponse( description='Improper "X-Broker-API-Originating-Identity" header. ' + str(e)) ), HTTPStatus.BAD_REQUEST else: request.originating_identity = None
Example 16
Project: virt-who Author: candlepin File: config.py License: GNU General Public License v2.0 | 6 votes |
def as_file(self): """If obj[%data_key_name] exists, return name of a file with base64 decoded obj[%data_key_name] content otherwise obj[%file_key_name].""" use_data_if_no_file = not self._file and self._data if use_data_if_no_file: if self._base64_file_content: if isinstance(self._data, str): content = self._data.encode() else: content = self._data self._file = _create_temp_file_with_content( base64.standard_b64decode(content)) else: self._file = _create_temp_file_with_content(self._data) if self._file and not os.path.isfile(self._file): raise ConfigException("File does not exists: %s" % self._file) return self._file
Example 17
Project: insightconnect-plugins Author: rapid7 File: action.py License: MIT License | 5 votes |
def run(self, params={}): raw = base64.standard_b64decode(params[Input.BYTES]) md5 = hashlib.md5(raw).hexdigest() # nosec sha1 = hashlib.sha1(raw).hexdigest() # nosec sha256 = hashlib.sha256(raw).hexdigest() sha512 = hashlib.sha512(raw).hexdigest() hashes = { Output.MD5: md5, Output.SHA1: sha1, Output.SHA256: sha256, Output.SHA512: sha512, } return hashes
Example 18
Project: insightconnect-plugins Author: rapid7 File: action.py License: MIT License | 5 votes |
def run(self, params={}): string_to_analyze = params.get(Input.BYTES_TO_ANALYZE) bytes_to_analyze = base64.standard_b64decode(string_to_analyze) output = chardet.detect(bytes_to_analyze) return {Output.RECOMMENDATION: output}
Example 19
Project: ironpython2 Author: IronLanguages File: test_base64.py License: Apache License 2.0 | 5 votes |
def test_b64decode(self): eq = self.assertEqual eq(base64.b64decode("d3d3LnB5dGhvbi5vcmc="), "www.python.org") eq(base64.b64decode('AA=='), '\x00') eq(base64.b64decode("YQ=="), "a") eq(base64.b64decode("YWI="), "ab") eq(base64.b64decode("YWJj"), "abc") eq(base64.b64decode("YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNE" "RUZHSElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0\nNT" "Y3ODkhQCMwXiYqKCk7Ojw+LC4gW117fQ=="), "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "0123456789!@#0^&*();:<>,. []{}") eq(base64.b64decode(''), '') # Test with arbitrary alternative characters eq(base64.b64decode('01a*b$cd', altchars='*$'), '\xd3V\xbeo\xf7\x1d') # Non-bytes eq(base64.b64decode(bytearray("YWJj")), "abc") # Test standard alphabet eq(base64.standard_b64decode("d3d3LnB5dGhvbi5vcmc="), "www.python.org") eq(base64.standard_b64decode("YQ=="), "a") eq(base64.standard_b64decode("YWI="), "ab") eq(base64.standard_b64decode("YWJj"), "abc") eq(base64.standard_b64decode(""), "") eq(base64.standard_b64decode("YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNE" "RUZHSElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0NT" "Y3ODkhQCMwXiYqKCk7Ojw+LC4gW117fQ=="), "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "0123456789!@#0^&*();:<>,. []{}") # Non-bytes eq(base64.standard_b64decode(bytearray("YWJj")), "abc") # Test with 'URL safe' alternative characters eq(base64.urlsafe_b64decode('01a-b_cd'), '\xd3V\xbeo\xf7\x1d') # Non-bytes eq(base64.urlsafe_b64decode(bytearray('01a-b_cd')), '\xd3V\xbeo\xf7\x1d')
Example 20
Project: Some-Examples-of-Simple-Python-Script Author: agusmakmun File: base64_enc_dec.py License: GNU Affero General Public License v3.0 | 5 votes |
def _base64_standard_decode(self, decode_string): #sample string: 'c3Nz' decoder = base64.standard_b64decode(decode_string) return decoder
Example 21
Project: BinderFilter Author: dxwu File: test_base64.py License: MIT License | 5 votes |
def test_b64decode(self): eq = self.assertEqual eq(base64.b64decode("d3d3LnB5dGhvbi5vcmc="), "www.python.org") eq(base64.b64decode('AA=='), '\x00') eq(base64.b64decode("YQ=="), "a") eq(base64.b64decode("YWI="), "ab") eq(base64.b64decode("YWJj"), "abc") eq(base64.b64decode("YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNE" "RUZHSElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0\nNT" "Y3ODkhQCMwXiYqKCk7Ojw+LC4gW117fQ=="), "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "0123456789!@#0^&*();:<>,. []{}") eq(base64.b64decode(''), '') # Test with arbitrary alternative characters eq(base64.b64decode('01a*b$cd', altchars='*$'), '\xd3V\xbeo\xf7\x1d') # Non-bytes eq(base64.b64decode(bytearray("YWJj")), "abc") # Test standard alphabet eq(base64.standard_b64decode("d3d3LnB5dGhvbi5vcmc="), "www.python.org") eq(base64.standard_b64decode("YQ=="), "a") eq(base64.standard_b64decode("YWI="), "ab") eq(base64.standard_b64decode("YWJj"), "abc") eq(base64.standard_b64decode(""), "") eq(base64.standard_b64decode("YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNE" "RUZHSElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0NT" "Y3ODkhQCMwXiYqKCk7Ojw+LC4gW117fQ=="), "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "0123456789!@#0^&*();:<>,. []{}") # Non-bytes eq(base64.standard_b64decode(bytearray("YWJj")), "abc") # Test with 'URL safe' alternative characters eq(base64.urlsafe_b64decode('01a-b_cd'), '\xd3V\xbeo\xf7\x1d') # Non-bytes eq(base64.urlsafe_b64decode(bytearray('01a-b_cd')), '\xd3V\xbeo\xf7\x1d')
Example 22
Project: plugin.video.netflix Author: CastagnaIT File: android_crypto.py License: MIT License | 5 votes |
def load_crypto_session(self, msl_data=None): if not msl_data: return self.keyset_id = base64.standard_b64decode(msl_data['key_set_id']) self.key_id = base64.standard_b64decode(msl_data['key_id']) self.hmac_key_id = base64.standard_b64decode(msl_data['hmac_key_id']) self.crypto_session.RestoreKeys(self.keyset_id)
Example 23
Project: plugin.video.netflix Author: CastagnaIT File: android_crypto.py License: MIT License | 5 votes |
def _init_keys(self, key_response_data): key_response = base64.standard_b64decode( key_response_data['keydata']['cdmkeyresponse']) self._provide_key_response(key_response) self.key_id = base64.standard_b64decode( key_response_data['keydata']['encryptionkeyid']) self.hmac_key_id = base64.standard_b64decode( key_response_data['keydata']['hmackeyid'])
Example 24
Project: plugin.video.netflix Author: CastagnaIT File: msl_request_builder.py License: MIT License | 5 votes |
def decrypt_header_data(self, data, enveloped=True): """Decrypt a message header""" header_data = json.loads(base64.standard_b64decode(data)) if enveloped: init_vector = base64.standard_b64decode(header_data['iv']) cipher_text = base64.standard_b64decode(header_data['ciphertext']) return json.loads(self.crypto.decrypt(init_vector, cipher_text)) return header_data
Example 25
Project: plugin.video.netflix Author: CastagnaIT File: default_crypto.py License: MIT License | 5 votes |
def load_crypto_session(self, msl_data=None): try: self.encryption_key = base64.standard_b64decode( msl_data['encryption_key']) self.sign_key = base64.standard_b64decode( msl_data['sign_key']) if not self.encryption_key or not self.sign_key: raise MSLError('Missing encryption_key or sign_key') self.rsa_key = RSA.importKey( base64.standard_b64decode(msl_data['rsa_key'])) except Exception: # pylint: disable=broad-except common.debug('Generating new RSA keys') self.rsa_key = RSA.generate(2048) self.encryption_key = None self.sign_key = None
Example 26
Project: plugin.video.netflix Author: CastagnaIT File: converter.py License: MIT License | 5 votes |
def _add_protection_info(adaptation_set, pssh, keyid): if keyid: # Signaling presence of encrypted content from base64 import standard_b64decode ET.SubElement( adaptation_set, # Parent 'ContentProtection', # Tag attrib={ 'schemeIdUri': 'urn:mpeg:dash:mp4protection:2011', 'cenc:default_KID': str(uuid.UUID(bytes=standard_b64decode(keyid))), 'value': 'cenc' }) # Define the DRM system configuration protection = ET.SubElement( adaptation_set, # Parent 'ContentProtection', # Tag attrib={ 'schemeIdUri': 'urn:uuid:EDEF8BA9-79D6-4ACE-A3C8-27DCD51D21ED', 'value': 'widevine' }) # Add child tags to the DRM system configuration ('widevine:license' is an ISA custom tag) if (g.LOCAL_DB.get_value('drm_security_level', '', table=TABLE_SESSION) == 'L1' and not g.ADDON.getSettingBool('force_widevine_l3')): # The flag HW_SECURE_CODECS_REQUIRED is mandatory for L1 devices, # if it is set on L3 devices ISA already remove it automatically. # But some L1 devices with non regular Widevine library cause issues then need to be handled robustness_level = 'HW_SECURE_CODECS_REQUIRED' else: robustness_level = '' ET.SubElement( protection, # Parent 'widevine:license', # Tag robustness_level=robustness_level) if pssh: ET.SubElement(protection, 'cenc:pssh').text = pssh
Example 27
Project: plugin.video.netflix Author: CastagnaIT File: base_crypto.py License: MIT License | 5 votes |
def _mastertoken_is_newer_that(self, mastertoken): """Check if current MasterToken is newer than mastertoken specified""" # Based on cadmium player sourcecode and ref. to [isNewerThan] in: # https://github.com/Netflix/msl/blob/master/core/src/main/java/com/netflix/msl/tokens/MasterToken.java new_tokendata = json.loads( base64.standard_b64decode(mastertoken['tokendata'].encode('utf-8')).decode('utf-8')) if new_tokendata['sequencenumber'] == self.sequence_number: return new_tokendata['expiration'] > self.expiration if new_tokendata['sequencenumber'] > self.sequence_number: cut_off = new_tokendata['sequencenumber'] - pow(2, 53) + 127 return self.sequence_number >= cut_off cut_off = self.sequence_number - pow(2, 53) + 127 return new_tokendata['sequencenumber'] < cut_off
Example 28
Project: plugin.video.netflix Author: CastagnaIT File: base_crypto.py License: MIT License | 5 votes |
def set_mastertoken(self, mastertoken): """Set the MasterToken and check it for validity""" tokendata = json.loads( base64.standard_b64decode(mastertoken['tokendata'].encode('utf-8')).decode('utf-8')) self.mastertoken = mastertoken self.serial_number = tokendata['serialnumber'] self.sequence_number = tokendata.get('sequencenumber', 0) self.renewal_window = tokendata['renewalwindow'] self.expiration = tokendata['expiration']
Example 29
Project: plugin.video.netflix Author: CastagnaIT File: base_crypto.py License: MIT License | 5 votes |
def is_user_id_token_expired(self, user_id_token): """Check if user id token is expired""" token_data = json.loads(base64.standard_b64decode(user_id_token['tokendata'])) # Subtract 5min as a safety measure return (token_data['expiration'] - 300) < time.time()
Example 30
Project: plugin.video.netflix Author: CastagnaIT File: msl_requests.py License: MIT License | 5 votes |
def _get_error_details(decoded_response): # Catch a chunk error if 'errordata' in decoded_response: return g.py2_encode(json.loads(base64.standard_b64decode(decoded_response['errordata']))['errormsg']) # Catch a manifest error if 'error' in decoded_response: if decoded_response['error'].get('errorDisplayMessage'): return g.py2_encode(decoded_response['error']['errorDisplayMessage']) # Catch a license error if 'result' in decoded_response and isinstance(decoded_response.get('result'), list): if 'error' in decoded_response['result'][0]: if decoded_response['result'][0]['error'].get('errorDisplayMessage'): return g.py2_encode(decoded_response['result'][0]['error']['errorDisplayMessage']) return g.py2_encode('Unhandled error check log.')