Improved compatibility with Java

This commit is contained in:
kokarare1212 2021-03-07 14:38:41 +09:00
parent da55d907ee
commit ba29d64c2d
2 changed files with 10 additions and 10 deletions

View File

@ -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

View File

@ -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: