diff --git a/librespot/core/ApResolver.py b/librespot/core/ApResolver.py index 119a886..1bf4480 100644 --- a/librespot/core/ApResolver.py +++ b/librespot/core/ApResolver.py @@ -7,8 +7,7 @@ class ApResolver: @staticmethod def request(service_type: str): - response = requests.get("{}?type={}".format(ApResolver.base_url, - service_type)) + response = requests.get("{}?type={}".format(ApResolver.base_url, service_type)) return response.json() @staticmethod diff --git a/librespot/crypto/DiffieHellman.py b/librespot/crypto/DiffieHellman.py index 6e2442e..39df0f1 100644 --- a/librespot/crypto/DiffieHellman.py +++ b/librespot/crypto/DiffieHellman.py @@ -3,16 +3,106 @@ import os class DiffieHellman: - prime_bytes: bytearray = bytes([ - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc9, 0x0f, 0xda, 0xa2, - 0x21, 0x68, 0xc2, 0x34, 0xc4, 0xc6, 0x62, 0x8b, 0x80, 0xdc, 0x1c, 0xd1, - 0x29, 0x02, 0x4e, 0x08, 0x8a, 0x67, 0xcc, 0x74, 0x02, 0x0b, 0xbe, 0xa6, - 0x3b, 0x13, 0x9b, 0x22, 0x51, 0x4a, 0x08, 0x79, 0x8e, 0x34, 0x04, 0xdd, - 0xef, 0x95, 0x19, 0xb3, 0xcd, 0x3a, 0x43, 0x1b, 0x30, 0x2b, 0x0a, 0x6d, - 0xf2, 0x5f, 0x14, 0x37, 0x4f, 0xe1, 0x35, 0x6d, 0x6d, 0x51, 0xc2, 0x45, - 0xe4, 0x85, 0xb5, 0x76, 0x62, 0x5e, 0x7e, 0xc6, 0xf4, 0x4c, 0x42, 0xe9, - 0xa6, 0x3a, 0x36, 0x20, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff - ]) + prime_bytes: bytearray = bytes( + [ + 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0xC9, + 0x0F, + 0xDA, + 0xA2, + 0x21, + 0x68, + 0xC2, + 0x34, + 0xC4, + 0xC6, + 0x62, + 0x8B, + 0x80, + 0xDC, + 0x1C, + 0xD1, + 0x29, + 0x02, + 0x4E, + 0x08, + 0x8A, + 0x67, + 0xCC, + 0x74, + 0x02, + 0x0B, + 0xBE, + 0xA6, + 0x3B, + 0x13, + 0x9B, + 0x22, + 0x51, + 0x4A, + 0x08, + 0x79, + 0x8E, + 0x34, + 0x04, + 0xDD, + 0xEF, + 0x95, + 0x19, + 0xB3, + 0xCD, + 0x3A, + 0x43, + 0x1B, + 0x30, + 0x2B, + 0x0A, + 0x6D, + 0xF2, + 0x5F, + 0x14, + 0x37, + 0x4F, + 0xE1, + 0x35, + 0x6D, + 0x6D, + 0x51, + 0xC2, + 0x45, + 0xE4, + 0x85, + 0xB5, + 0x76, + 0x62, + 0x5E, + 0x7E, + 0xC6, + 0xF4, + 0x4C, + 0x42, + 0xE9, + 0xA6, + 0x3A, + 0x36, + 0x20, + 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0xFF, + ] + ) prime: int = int.from_bytes(prime_bytes, "big") private_key: int public_key: int diff --git a/librespot/standard/DataInputStream.py b/librespot/standard/DataInputStream.py index 857bbb7..5a59d56 100644 --- a/librespot/standard/DataInputStream.py +++ b/librespot/standard/DataInputStream.py @@ -3,20 +3,16 @@ from librespot.standard.FilterInputStream import FilterInputStream class DataInputStream(FilterInputStream, DataInput): - def read(self, - b: bytearray = None, - offset: int = None, - length: int = None) -> int: + def read(self, b: bytearray = None, offset: int = None, length: int = None) -> int: if b is not None and offset is None and length is None: return self.input_stream.read(b, 0, len(b)) if b is not None and offset is not None and length is not None: return self.input_stream.read(b, offset, length) raise TypeError() - def read_fully(self, - b: bytearray = None, - offset: int = None, - length: int = None) -> None: + def read_fully( + self, b: bytearray = None, offset: int = None, length: int = None + ) -> None: if b is not None and offset is None and length is None: offset = 0 length = len(b) @@ -94,14 +90,16 @@ class DataInputStream(FilterInputStream, DataInput): def read_long(self) -> int: self.read_fully(self.read_buffer, 0, 8) - return (self.read_buffer[0] << 56) + \ - ((self.read_buffer[1] & 255) << 48) + \ - ((self.read_buffer[2] & 255) << 40) + \ - ((self.read_buffer[3] & 255) << 32) + \ - ((self.read_buffer[4] & 255) << 24) + \ - ((self.read_buffer[5] & 255) << 16) + \ - ((self.read_buffer[6] & 255) << 8) + \ - ((self.read_buffer[7] & 255) << 0) + return ( + (self.read_buffer[0] << 56) + + ((self.read_buffer[1] & 255) << 48) + + ((self.read_buffer[2] & 255) << 40) + + ((self.read_buffer[3] & 255) << 32) + + ((self.read_buffer[4] & 255) << 24) + + ((self.read_buffer[5] & 255) << 16) + + ((self.read_buffer[6] & 255) << 8) + + ((self.read_buffer[7] & 255) << 0) + ) def read_float(self) -> float: pass