From ba29d64c2d28e22e2496bf27fc1a39cee3ff1b7a Mon Sep 17 00:00:00 2001 From: kokarare1212 Date: Sun, 7 Mar 2021 14:38:41 +0900 Subject: [PATCH] Improved compatibility with Java --- librespot/audio/AudioKeyManager.py | 14 +++++++------- librespot/core/Session.py | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/librespot/audio/AudioKeyManager.py b/librespot/audio/AudioKeyManager.py index 2f10285..6342713 100644 --- a/librespot/audio/AudioKeyManager.py +++ b/librespot/audio/AudioKeyManager.py @@ -3,7 +3,7 @@ from librespot.common import Utils from librespot.core import Session from librespot.core.PacketsReceiver import PacketsReceiver from librespot.crypto import Packet -from librespot.standard import BytesInputStream, BytesOutputStream +from librespot.standard import BytesInputStream, ByteArrayOutputStream import logging import queue import threading @@ -30,13 +30,13 @@ class AudioKeyManager(PacketsReceiver): seq = self._seqHolder self._seqHolder += 1 - out = BytesOutputStream() - out.write(file_id) - out.write(gid) - out.write_int(seq) - out.write(self._ZERO_SHORT) + out = ByteArrayOutputStream() + out.write(buffer=bytearray(file_id)) + out.write(buffer=bytearray(gid)) + out.write(buffer=bytearray(Utils.to_byte_array(seq))) + out.write(buffer=bytearray(self._ZERO_SHORT)) - self._session.send(Packet.Type.request_key, out.buffer) + self._session.send(Packet.Type.request_key, out.to_bytes()) callback = AudioKeyManager.SyncCallback(self) self._callbacks[seq] = callback diff --git a/librespot/core/Session.py b/librespot/core/Session.py index 10c9bf3..5285b05 100644 --- a/librespot/core/Session.py +++ b/librespot/core/Session.py @@ -233,8 +233,8 @@ class Session(Closeable, SubListener, DealerClient.MessageListener): self._LOGGER.info("Connection successfully!") - def authenticate(self, - credentials: Authentication.LoginCredentials) -> None: + def _authenticate(self, + credentials: Authentication.LoginCredentials) -> None: self._authenticate_partial(credentials, False) with self._authLock: @@ -707,7 +707,7 @@ class Session(Closeable, SubListener, DealerClient.MessageListener): self.device_id), ApResolver.get_random_accesspoint()) session._connect() - session.authenticate(self.login_credentials) + session._authenticate(self.login_credentials) return session class Configuration: