Fix python3 in pssh-box
The script now works with both python 2 and python 3 (tested with python 2.7 and python 3.8.6). Fixes #833.
This commit is contained in:
parent
346c844e42
commit
c6b01f90ae
|
@ -124,7 +124,7 @@ class Pssh(object):
|
|||
lines.extend([' ' + x for x in extra])
|
||||
# pylint: disable=broad-except
|
||||
except Exception as e:
|
||||
lines.append(' ERROR: ' + e.message)
|
||||
lines.append(' ERROR: ' + str(e))
|
||||
else:
|
||||
lines.extend([
|
||||
' Raw Data (base64):',
|
||||
|
@ -141,14 +141,14 @@ def _split_list_on(elems, sep):
|
|||
|
||||
|
||||
def _create_bin_int(value):
|
||||
"""Creates a 4-byte binary string from the given integer."""
|
||||
"""Creates a binary string as 4-byte array from the given integer."""
|
||||
return (chr(value >> 24) + chr((value >> 16) & 0xff) +
|
||||
chr((value >> 8) & 0xff) + chr(value & 0xff))
|
||||
chr((value >> 8) & 0xff) + chr(value & 0xff)).encode()
|
||||
|
||||
|
||||
def _create_uuid(data):
|
||||
"""Creates a human readable UUID string from the given binary string."""
|
||||
ret = base64.b16encode(data).lower()
|
||||
ret = base64.b16encode(data).decode().lower()
|
||||
return (ret[:8] + '-' + ret[8:12] + '-' + ret[12:16] + '-' + ret[16:20] +
|
||||
'-' + ret[20:])
|
||||
|
||||
|
@ -180,7 +180,7 @@ def _parse_widevine_data(data):
|
|||
if wv.HasField('provider'):
|
||||
ret.append('Provider: ' + wv.provider)
|
||||
if wv.HasField('content_id'):
|
||||
ret.append('Content ID: ' + base64.b16encode(wv.content_id))
|
||||
ret.append('Content ID: ' + base64.b16encode(wv.content_id).decode())
|
||||
if wv.HasField('policy'):
|
||||
ret.append('Policy: ' + wv.policy)
|
||||
if wv.HasField('crypto_period_index'):
|
||||
|
@ -423,11 +423,11 @@ def main(all_args):
|
|||
for box in boxes:
|
||||
print(box.human_string())
|
||||
else:
|
||||
box_data = ''.join([x.binary_string() for x in boxes])
|
||||
box_data = b''.join([x.binary_string() for x in boxes])
|
||||
if output_format == 'hex':
|
||||
print(base64.b16encode(box_data))
|
||||
print(base64.b16encode(box_data).decode())
|
||||
else:
|
||||
print(base64.b64encode(box_data))
|
||||
print(base64.b64encode(box_data).decode())
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
Loading…
Reference in New Issue