Format code with yapf
This commit fixes the style issues introduced in 3df41f0 according to the output
from yapf.
Details: https://deepsource.io/gh/kokarare1212/librespot-python/transform/8943cbb4-879c-4a5f-8f77-e14c8c5ac178/
This commit is contained in:
committed by
GitHub
parent
3df41f04fc
commit
45e69da1a8
@@ -34,7 +34,8 @@ class Player(Closeable, PlayerSession.Listener, AudioSink.Listener):
|
||||
self._init_state()
|
||||
|
||||
def _init_state(self):
|
||||
self._state = StateWrapper.StateWrapper(self._session, self, self._conf)
|
||||
self._state = StateWrapper.StateWrapper(self._session, self,
|
||||
self._conf)
|
||||
|
||||
class Anonymous(DeviceStateHandler.Listener):
|
||||
_player: Player = None
|
||||
@@ -45,8 +46,10 @@ class Player(Closeable, PlayerSession.Listener, AudioSink.Listener):
|
||||
def ready(self) -> None:
|
||||
pass
|
||||
|
||||
def command(self, endpoint: DeviceStateHandler.Endpoint, data: DeviceStateHandler.CommandBody) -> None:
|
||||
self._player._LOGGER.debug("Received command: {}".format(endpoint))
|
||||
def command(self, endpoint: DeviceStateHandler.Endpoint,
|
||||
data: DeviceStateHandler.CommandBody) -> None:
|
||||
self._player._LOGGER.debug(
|
||||
"Received command: {}".format(endpoint))
|
||||
|
||||
self._deviceStateListener = Anonymous(self)
|
||||
self._state.add_listener(self._deviceStateListener)
|
||||
|
||||
@@ -21,29 +21,28 @@ class StateWrapper(DeviceStateHandler.Listener, DealerClient.MessageListener):
|
||||
self._state = self._init_state()
|
||||
|
||||
self._device.add_listener(self)
|
||||
self._session.dealer().add_message_listener(self, "spotify:user:attributes:update", "hm://playlist/", "hm://collection/collection/" + self._session.username() + "/json")
|
||||
self._session.dealer().add_message_listener(
|
||||
self, "spotify:user:attributes:update", "hm://playlist/",
|
||||
"hm://collection/collection/" + self._session.username() + "/json")
|
||||
|
||||
def _init_state(self) -> PlayerState:
|
||||
return PlayerState(
|
||||
playback_speed=1.0,
|
||||
suppressions=Suppressions(),
|
||||
context_restrictions=Restrictions(),
|
||||
options=ContextPlayerOptions(
|
||||
repeating_context=False,
|
||||
shuffling_context=False,
|
||||
repeating_track=False
|
||||
),
|
||||
position_as_of_timestamp=0,
|
||||
position=0,
|
||||
is_playing=False
|
||||
)
|
||||
return PlayerState(playback_speed=1.0,
|
||||
suppressions=Suppressions(),
|
||||
context_restrictions=Restrictions(),
|
||||
options=ContextPlayerOptions(
|
||||
repeating_context=False,
|
||||
shuffling_context=False,
|
||||
repeating_track=False),
|
||||
position_as_of_timestamp=0,
|
||||
position=0,
|
||||
is_playing=False)
|
||||
|
||||
def add_listener(self, listener: DeviceStateHandler.Listener):
|
||||
self._device.add_listener(listener)
|
||||
|
||||
def ready(self) -> None:
|
||||
self._device.update_state(Connect.PutStateReason.NEW_DEVICE, 0, self._state)
|
||||
self._device.update_state(Connect.PutStateReason.NEW_DEVICE, 0,
|
||||
self._state)
|
||||
|
||||
def on_message(self, uri: str, headers: dict[str, str],
|
||||
payload: bytes):
|
||||
def on_message(self, uri: str, headers: dict[str, str], payload: bytes):
|
||||
pass
|
||||
|
||||
@@ -3,7 +3,8 @@ from librespot.player import PlayerConfiguration
|
||||
|
||||
|
||||
class AudioSink:
|
||||
def __init__(self, conf: PlayerConfiguration, listener: AudioSink.Listener):
|
||||
def __init__(self, conf: PlayerConfiguration,
|
||||
listener: AudioSink.Listener):
|
||||
pass
|
||||
|
||||
class Listener:
|
||||
|
||||
@@ -18,7 +18,8 @@ class DeviceStateHandler:
|
||||
_deviceInfo: Connect.DeviceInfo = None
|
||||
_listeners: list[DeviceStateHandler.Listener] = list()
|
||||
_putState: Connect.PutStateRequest = None
|
||||
_putStateWorker: concurrent.futures.ThreadPoolExecutor = concurrent.futures.ThreadPoolExecutor()
|
||||
_putStateWorker: concurrent.futures.ThreadPoolExecutor = concurrent.futures.ThreadPoolExecutor(
|
||||
)
|
||||
_connectionId: str = None
|
||||
|
||||
def __init__(self, session: Session, player, conf: PlayerConfiguration):
|
||||
@@ -32,7 +33,8 @@ class DeviceStateHandler:
|
||||
if self._connectionId is None or \
|
||||
self._connectionId != newer:
|
||||
self._connectionId = newer
|
||||
self._LOGGER.debug("Updated Spotify-Connection-Id: {}".format(self._connectionId))
|
||||
self._LOGGER.debug("Updated Spotify-Connection-Id: {}".format(
|
||||
self._connectionId))
|
||||
self._notify_ready()
|
||||
|
||||
def add_listener(self, listener: DeviceStateHandler.Listener):
|
||||
@@ -42,7 +44,8 @@ class DeviceStateHandler:
|
||||
for listener in self._listeners:
|
||||
listener.ready()
|
||||
|
||||
def update_state(self, reason: Connect.PutStateReason, player_time: int, state: Player.PlayerState):
|
||||
def update_state(self, reason: Connect.PutStateReason, player_time: int,
|
||||
state: Player.PlayerState):
|
||||
if self._connectionId is None:
|
||||
raise TypeError()
|
||||
|
||||
@@ -61,8 +64,9 @@ class DeviceStateHandler:
|
||||
def _put_connect_state(self, req: Connect.PutStateRequest):
|
||||
self._session.api().put_connect_state(self._connectionId, req)
|
||||
self._LOGGER.info("Put state. ts: {}, connId: {}, reason: {}".format(
|
||||
req.client_side_timestamp, Utils.truncate_middle(self._connectionId, 10), req.put_state_reason
|
||||
))
|
||||
req.client_side_timestamp,
|
||||
Utils.truncate_middle(self._connectionId, 10),
|
||||
req.put_state_reason))
|
||||
|
||||
class Endpoint(enum.Enum):
|
||||
Play: str = "play"
|
||||
@@ -76,7 +80,8 @@ class DeviceStateHandler:
|
||||
def ready(self) -> None:
|
||||
pass
|
||||
|
||||
def command(self, endpoint: DeviceStateHandler.Endpoint, data: DeviceStateHandler.CommandBody) -> None:
|
||||
def command(self, endpoint: DeviceStateHandler.Endpoint,
|
||||
data: DeviceStateHandler.CommandBody) -> None:
|
||||
pass
|
||||
|
||||
def volume_changed(self) -> None:
|
||||
|
||||
Reference in New Issue
Block a user