Restyled by yapf

This commit is contained in:
Restyled.io
2021-04-16 23:52:13 +00:00
parent d3febb34d5
commit 4b2c144aff
3 changed files with 116 additions and 115 deletions

View File

@@ -8,7 +8,8 @@ class ApResolver:
@staticmethod @staticmethod
def request(service_type: str): 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() return response.json()
@staticmethod @staticmethod

View File

@@ -4,106 +4,104 @@ from librespot.common.Utils import Utils
class DiffieHellman: class DiffieHellman:
prime_bytes: bytearray = bytes( prime_bytes: bytearray = bytes([
[ 0xFF,
0xFF, 0xFF,
0xFF, 0xFF,
0xFF, 0xFF,
0xFF, 0xFF,
0xFF, 0xFF,
0xFF, 0xFF,
0xFF, 0xFF,
0xFF, 0xC9,
0xC9, 0x0F,
0x0F, 0xDA,
0xDA, 0xA2,
0xA2, 0x21,
0x21, 0x68,
0x68, 0xC2,
0xC2, 0x34,
0x34, 0xC4,
0xC4, 0xC6,
0xC6, 0x62,
0x62, 0x8B,
0x8B, 0x80,
0x80, 0xDC,
0xDC, 0x1C,
0x1C, 0xD1,
0xD1, 0x29,
0x29, 0x02,
0x02, 0x4E,
0x4E, 0x08,
0x08, 0x8A,
0x8A, 0x67,
0x67, 0xCC,
0xCC, 0x74,
0x74, 0x02,
0x02, 0x0B,
0x0B, 0xBE,
0xBE, 0xA6,
0xA6, 0x3B,
0x3B, 0x13,
0x13, 0x9B,
0x9B, 0x22,
0x22, 0x51,
0x51, 0x4A,
0x4A, 0x08,
0x08, 0x79,
0x79, 0x8E,
0x8E, 0x34,
0x34, 0x04,
0x04, 0xDD,
0xDD, 0xEF,
0xEF, 0x95,
0x95, 0x19,
0x19, 0xB3,
0xB3, 0xCD,
0xCD, 0x3A,
0x3A, 0x43,
0x43, 0x1B,
0x1B, 0x30,
0x30, 0x2B,
0x2B, 0x0A,
0x0A, 0x6D,
0x6D, 0xF2,
0xF2, 0x5F,
0x5F, 0x14,
0x14, 0x37,
0x37, 0x4F,
0x4F, 0xE1,
0xE1, 0x35,
0x35, 0x6D,
0x6D, 0x6D,
0x6D, 0x51,
0x51, 0xC2,
0xC2, 0x45,
0x45, 0xE4,
0xE4, 0x85,
0x85, 0xB5,
0xB5, 0x76,
0x76, 0x62,
0x62, 0x5E,
0x5E, 0x7E,
0x7E, 0xC6,
0xC6, 0xF4,
0xF4, 0x4C,
0x4C, 0x42,
0x42, 0xE9,
0xE9, 0xA6,
0xA6, 0x3A,
0x3A, 0x36,
0x36, 0x20,
0x20, 0xFF,
0xFF, 0xFF,
0xFF, 0xFF,
0xFF, 0xFF,
0xFF, 0xFF,
0xFF, 0xFF,
0xFF, 0xFF,
0xFF, 0xFF,
0xFF, ])
]
)
prime: int = int.from_bytes(prime_bytes, "big") prime: int = int.from_bytes(prime_bytes, "big")
private_key: int private_key: int
public_key: int public_key: int

View File

@@ -3,16 +3,20 @@ from librespot.standard.FilterInputStream import FilterInputStream
class DataInputStream(FilterInputStream, DataInput): 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: if b is not None and offset is None and length is None:
return self.input_stream.read(b, 0, len(b)) return self.input_stream.read(b, 0, len(b))
if b is not None and offset is not None and length is not None: if b is not None and offset is not None and length is not None:
return self.input_stream.read(b, offset, length) return self.input_stream.read(b, offset, length)
raise TypeError() raise TypeError()
def read_fully( def read_fully(self,
self, b: bytearray = None, offset: int = None, length: int = None b: bytearray = None,
) -> None: offset: int = None,
length: int = None) -> None:
if b is not None and offset is None and length is None: if b is not None and offset is None and length is None:
offset = 0 offset = 0
length = len(b) length = len(b)
@@ -90,16 +94,14 @@ class DataInputStream(FilterInputStream, DataInput):
def read_long(self) -> int: def read_long(self) -> int:
self.read_fully(self.read_buffer, 0, 8) self.read_fully(self.read_buffer, 0, 8)
return ( return ((self.read_buffer[0] << 56) +
(self.read_buffer[0] << 56) ((self.read_buffer[1] & 255) << 48) +
+ ((self.read_buffer[1] & 255) << 48) ((self.read_buffer[2] & 255) << 40) +
+ ((self.read_buffer[2] & 255) << 40) ((self.read_buffer[3] & 255) << 32) +
+ ((self.read_buffer[3] & 255) << 32) ((self.read_buffer[4] & 255) << 24) +
+ ((self.read_buffer[4] & 255) << 24) ((self.read_buffer[5] & 255) << 16) +
+ ((self.read_buffer[5] & 255) << 16) ((self.read_buffer[6] & 255) << 8) +
+ ((self.read_buffer[6] & 255) << 8) ((self.read_buffer[7] & 255) << 0))
+ ((self.read_buffer[7] & 255) << 0)
)
def read_float(self) -> float: def read_float(self) -> float:
pass pass