diff --git a/librespot/core.py b/librespot/core.py index 4fd8afc..c9014d6 100644 --- a/librespot/core.py +++ b/librespot/core.py @@ -1097,10 +1097,13 @@ class Session(Closeable, MessageListener, SubListener): def blob(self, username: str, blob: bytes) -> Session.Builder: if self.device_id is None: raise TypeError("You must specify the device ID first.") - self.login_credentials = self.decrypt_blob(self.device_id, username, blob) + self.login_credentials = self.decrypt_blob(self.device_id, + username, blob) return self - def decrypt_blob(self, device_id: str, username: str, encrypted_blob: bytes) -> Authentication.LoginCredentials: + def decrypt_blob( + self, device_id: str, username: str, + encrypted_blob: bytes) -> Authentication.LoginCredentials: encrypted_blob = base64.b64decode(encrypted_blob) sha1 = SHA1.new() sha1.update(device_id.encode()) @@ -1119,7 +1122,9 @@ class Session(Closeable, MessageListener, SubListener): type_int = self.read_blob_int(blob) type_ = Authentication.AuthenticationType.Name(type_int) if type_ is None: - raise IOError(TypeError("Unknown AuthenticationType: {}".format(type_int))) + raise IOError( + TypeError( + "Unknown AuthenticationType: {}".format(type_int))) le = self.read_blob_int(blob) auth_data = blob.read(le) return Authentication.LoginCredentials( diff --git a/librespot/zeroconf.py b/librespot/zeroconf.py index d7fa5f9..87042e4 100644 --- a/librespot/zeroconf.py +++ b/librespot/zeroconf.py @@ -71,8 +71,8 @@ class ZeroconfServer(Closeable): "CPath": "/", "VERSION": "1.0", "STACK": "SP", - }, self.get_useful_hostname() + ".", - addresses=[socket.inet_aton(socket.gethostbyname(self.get_useful_hostname()))] + }, + inner.device_name, ) self.__zeroconf.register_service(self.__service_info) threading.Thread(target=self.__zeroconf.start, name="zeroconf-multicast-dns-server").start() @@ -81,13 +81,6 @@ class ZeroconfServer(Closeable): self.__zeroconf.close() self.__runner.close() - def get_useful_hostname(self) -> str: - host = socket.gethostname() - if host == "localhost": - pass - else: - return host - def handle_add_user(self, __socket: socket.socket, params: dict[str, str], http_version: str) -> None: username = params.get("userName") if not username: