diff --git a/docs/conf.py b/docs/conf.py index ba45e19..7f699a2 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -20,15 +20,12 @@ project = 'librespot-python' copyright = '2021, kokarare1212' author = 'kokarare1212' - # -- General configuration --------------------------------------------------- # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. -extensions = [ - 'recommonmark' -] +extensions = ['recommonmark'] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] @@ -38,7 +35,6 @@ templates_path = ['_templates'] # This pattern also affects html_static_path and html_extra_path. exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] - # -- Options for HTML output ------------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for @@ -51,7 +47,6 @@ html_theme = 'sphinx_rtd_theme' # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] - # -- Markdown ---------------------------------------------------------------- source_suffix = ['.rst', '.md'] @@ -59,4 +54,3 @@ source_suffix = ['.rst', '.md'] source_parsers = { '.md': 'recommonmark.parser.CommonMarkParser', } - diff --git a/librespot/metadata/AlbumId.py b/librespot/metadata/AlbumId.py index c5b2872..63688fe 100644 --- a/librespot/metadata/AlbumId.py +++ b/librespot/metadata/AlbumId.py @@ -25,8 +25,7 @@ class AlbumId(SpotifyId.SpotifyId): @staticmethod def from_base62(base62: str) -> AlbumId: - return AlbumId( - Utils.bytes_to_hex(AlbumId._BASE62.decode(base62, 16))) + return AlbumId(Utils.bytes_to_hex(AlbumId._BASE62.decode(base62, 16))) @staticmethod def from_hex(hex_str: str) -> AlbumId: diff --git a/librespot/metadata/ArtistId.py b/librespot/metadata/ArtistId.py index 1c30128..094cb4d 100644 --- a/librespot/metadata/ArtistId.py +++ b/librespot/metadata/ArtistId.py @@ -18,15 +18,14 @@ class ArtistId(SpotifyId.SpotifyId): if matcher is not None: artist_id = matcher.group(1) return ArtistId( - Utils.bytes_to_hex(ArtistId._BASE62.decode( - artist_id, 16))) + Utils.bytes_to_hex(ArtistId._BASE62.decode(artist_id, 16))) else: raise TypeError("Not a Spotify artist ID: {}".format(uri)) @staticmethod def from_base62(base62: str) -> ArtistId: - return ArtistId( - Utils.bytes_to_hex(ArtistId._BASE62.decode(base62, 16))) + return ArtistId(Utils.bytes_to_hex(ArtistId._BASE62.decode(base62, + 16))) @staticmethod def from_hex(hex_str: str) -> ArtistId: diff --git a/librespot/metadata/ShowId.py b/librespot/metadata/ShowId.py index d6c2a7f..c236641 100644 --- a/librespot/metadata/ShowId.py +++ b/librespot/metadata/ShowId.py @@ -24,8 +24,7 @@ class ShowId(SpotifyId.SpotifyId): @staticmethod def from_base62(base62: str) -> ShowId: - return ShowId( - Utils.bytes_to_hex(ShowId._BASE62.decode(base62, 16))) + return ShowId(Utils.bytes_to_hex(ShowId._BASE62.decode(base62, 16))) @staticmethod def from_hex(hex_str: str) -> ShowId: diff --git a/librespot/metadata/TrackId.py b/librespot/metadata/TrackId.py index 69fb6a2..8206a0d 100644 --- a/librespot/metadata/TrackId.py +++ b/librespot/metadata/TrackId.py @@ -18,15 +18,14 @@ class TrackId(PlayableId, SpotifyId): if search is not None: track_id = search.group(1) return TrackId( - Utils.bytes_to_hex(PlayableId.BASE62.decode( - track_id, 16))) + Utils.bytes_to_hex(PlayableId.BASE62.decode(track_id, 16))) else: raise RuntimeError("Not a Spotify track ID: {}".format(uri)) @staticmethod def from_base62(base62: str) -> TrackId: - return TrackId( - Utils.bytes_to_hex(PlayableId.BASE62.decode(base62, 16))) + return TrackId(Utils.bytes_to_hex(PlayableId.BASE62.decode(base62, + 16))) @staticmethod def from_hex(hex_str: str) -> TrackId: diff --git a/librespot/player/Player.py b/librespot/player/Player.py index 6e34420..6f58c6c 100644 --- a/librespot/player/Player.py +++ b/librespot/player/Player.py @@ -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) diff --git a/librespot/player/StateWrapper.py b/librespot/player/StateWrapper.py index f46f768..d2ef8ef 100644 --- a/librespot/player/StateWrapper.py +++ b/librespot/player/StateWrapper.py @@ -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 diff --git a/librespot/player/mixing/AudioSink.py b/librespot/player/mixing/AudioSink.py index 5e4234b..85ecb3b 100644 --- a/librespot/player/mixing/AudioSink.py +++ b/librespot/player/mixing/AudioSink.py @@ -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: diff --git a/librespot/player/state/DeviceStateHandler.py b/librespot/player/state/DeviceStateHandler.py index 32216f6..ce622b3 100644 --- a/librespot/player/state/DeviceStateHandler.py +++ b/librespot/player/state/DeviceStateHandler.py @@ -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: