diff --git a/librespot/core/ApResolver.py b/librespot/core/ApResolver.py index 733eaa1..6652514 100644 --- a/librespot/core/ApResolver.py +++ b/librespot/core/ApResolver.py @@ -1,5 +1,5 @@ -import queue import random + import requests diff --git a/librespot/crypto/DiffieHellman.py b/librespot/crypto/DiffieHellman.py index 16fe59a..e61c1ce 100644 --- a/librespot/crypto/DiffieHellman.py +++ b/librespot/crypto/DiffieHellman.py @@ -1,19 +1,106 @@ -from binascii import unhexlify -from librespot.common.Utils import Utils import os -import struct + +from librespot.common.Utils import Utils 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 + 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 diff --git a/librespot/standard/DataInputStream.py b/librespot/standard/DataInputStream.py index aaffe89..063d389 100644 --- a/librespot/standard/DataInputStream.py +++ b/librespot/standard/DataInputStream.py @@ -1,6 +1,5 @@ from librespot.standard.DataInput import DataInput from librespot.standard.FilterInputStream import FilterInputStream -from librespot.standard.InputStream import InputStream class DataInputStream(FilterInputStream, DataInput): @@ -95,14 +94,14 @@ 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