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 import Session
from librespot.core.PacketsReceiver import PacketsReceiver from librespot.core.PacketsReceiver import PacketsReceiver
from librespot.crypto import Packet from librespot.crypto import Packet
from librespot.standard import BytesInputStream, BytesOutputStream from librespot.standard import BytesInputStream, ByteArrayOutputStream
import logging import logging
import queue import queue
import threading import threading
@ -30,13 +30,13 @@ class AudioKeyManager(PacketsReceiver):
seq = self._seqHolder seq = self._seqHolder
self._seqHolder += 1 self._seqHolder += 1
out = BytesOutputStream() out = ByteArrayOutputStream()
out.write(file_id) out.write(buffer=bytearray(file_id))
out.write(gid) out.write(buffer=bytearray(gid))
out.write_int(seq) out.write(buffer=bytearray(Utils.to_byte_array(seq)))
out.write(self._ZERO_SHORT) 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) callback = AudioKeyManager.SyncCallback(self)
self._callbacks[seq] = callback self._callbacks[seq] = callback

View File

@ -233,8 +233,8 @@ class Session(Closeable, SubListener, DealerClient.MessageListener):
self._LOGGER.info("Connection successfully!") self._LOGGER.info("Connection successfully!")
def authenticate(self, def _authenticate(self,
credentials: Authentication.LoginCredentials) -> None: credentials: Authentication.LoginCredentials) -> None:
self._authenticate_partial(credentials, False) self._authenticate_partial(credentials, False)
with self._authLock: with self._authLock:
@ -707,7 +707,7 @@ class Session(Closeable, SubListener, DealerClient.MessageListener):
self.device_id), self.device_id),
ApResolver.get_random_accesspoint()) ApResolver.get_random_accesspoint())
session._connect() session._connect()
session.authenticate(self.login_credentials) session._authenticate(self.login_credentials)
return session return session
class Configuration: class Configuration: