spicetify-websocket 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Tobias Schmitt
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,115 @@
1
+ Metadata-Version: 2.4
2
+ Name: spicetify-websocket
3
+ Version: 0.1.0
4
+ Summary: An asynchronous Python wrapper and WebSocket server for controlling the Spotify desktop client via Spicetify and the spicetify-connect-api extension.
5
+ Author-email: Tobias Schmitt <support@tobfd.de>
6
+ License-Expression: MIT
7
+ Project-URL: Github, https://github.com/tobfd/spicetify-websocket
8
+ Project-URL: Documentation, https://spicetify-websocket.readthedocs.io
9
+ Project-URL: Changelog, https://github.com/tobfd/spicetify-websocket/releases
10
+ Keywords: spicetify,websocket,local,spotify
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Programming Language :: Python :: 3.14
19
+ Classifier: Operating System :: OS Independent
20
+ Classifier: Topic :: Utilities
21
+ Classifier: Topic :: Software Development :: Libraries
22
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
+ Requires-Python: >=3.10
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Requires-Dist: pydantic<3.0,>=2.13.4
27
+ Requires-Dist: websockets<17.0,>=16.1.1
28
+ Dynamic: license-file
29
+
30
+ [![spicetify-websocket](https://github.com/tobfd/spicetify-websocket/blob/master/docs/_static/logo.png?raw=true)](https://github.com/tobfd/spicetify-websocket)
31
+
32
+ [![PyPI Version](https://img.shields.io/pypi/v/spicetify-websocket?style=for-the-badge&logo=pypi&logoColor=white&color=magenta)](https://pypi.org/project/spicetify-websocket/)
33
+ [![GitHub License](https://img.shields.io/github/license/tobfd/spicetify-websocket?style=for-the-badge&logo=github&color=red)](https://github.com/tobfd/spicetify-websocket/blob/master/LICENSE)
34
+ [![](https://img.shields.io/badge/python-3.10%2B-blue.svg?style=for-the-badge&logo=python&logoColor=white)](https://www.python.org/)
35
+ [![Read the Docs](https://img.shields.io/readthedocs/spicetify-websocket?style=for-the-badge&logo=readthedocs)](https://spicetify-websocket.readthedocs.io/)
36
+
37
+ An asynchronous Python wrapper and WebSocket server for controlling the Spotify desktop client via [Spicetify](https://spicetify.app/) and the [spicetify-connect-api]([https://github.com/tobfd/spicetify-connect-api) extension.
38
+
39
+ ## ✨ Features
40
+
41
+ - ⚡ **Real-time Push Events:** Instant updates for song changes, volume, seeking, and playback state.
42
+ - 🎮 **Full Playback Control:** Play, pause, skip, seek, volume, repeat, and shuffle.
43
+ - 🛠️ **Convenience Decorators:** Easy event listening with syntax like `@server.on_song_changed`.
44
+ - 🏷️ **Fully Typed:** Pydantic V2 models (`TrackInfo`, `PlayerState`, `RepeatMode`).
45
+ - 🔄 **Async & Non-blocking:** Built on `asyncio` and `websockets` for maximum performance.
46
+ ---
47
+
48
+ ## ⚙️ Installation
49
+
50
+ Python 3.10 or higher is required.
51
+
52
+ ```bash
53
+ pip install spicetify-websocket
54
+ ```
55
+
56
+ ---
57
+
58
+ ## 📋 Prerequisites
59
+
60
+ To use this library, ensure you have:
61
+ 1. **Spotify Desktop Client** installed.
62
+ 2. **[Spicetify CLI](https://spicetify.app/)** installed and configured.
63
+ 3. The [spicetify-connect-api]([https://github.com/tobfd/spicetify-connect-api) extension enabled in Spicetify.
64
+
65
+ ---
66
+
67
+ ## 🚀 Example Usage
68
+
69
+ ```python
70
+ import asyncio
71
+ from spicetify import RepeatMode, SpotifyServer, TrackInfo
72
+
73
+
74
+ async def main():
75
+ async with SpotifyServer() as server:
76
+ # Wait until Spicetify client connects
77
+ await server.wait_for_connection()
78
+
79
+ # Playback Controls
80
+ await server.play_url(url="https://open.spotify.com/intl-de/track/55pBIZO1cqoldeqpp5WR7H?si=57cde33a1bd34ac9")
81
+ await server.set_volume(percent=75)
82
+ await server.set_repeat(mode=RepeatMode.TRACK)
83
+
84
+ # Playback State
85
+ current_track: TrackInfo = await server.get_current_track()
86
+ print(current_track)
87
+
88
+ # Events
89
+ @server.on_song_changed
90
+ def callback(track: TrackInfo):
91
+ print("New song is playing:", track.title)
92
+ print("Artist/s:", ", ".join(artist.name for artist in track.artists))
93
+
94
+ # Keep the server running to receive events
95
+ await asyncio.Event().wait()
96
+
97
+
98
+ if __name__ == "__main__":
99
+ asyncio.run(main())
100
+ ```
101
+
102
+ ---
103
+
104
+ ## 📻 Events Reference
105
+
106
+ | Event Name | Convenience Decorator | Callback Payload Type | Description |
107
+ | :--- | :--- | :--- | :--- |
108
+ | `InitialState` | `@server.on_initial_state` | `PlayerState` | Fired immediately when Spicetify connects. |
109
+ | `SongChanged` | `@server.on_song_changed` | `TrackInfo` | Fired when a new track starts playing. |
110
+ | `PlayPauseChanged` | `@server.on_play_pause_changed` | `PlayerState` | Fired when playback state changes. |
111
+ | `VolumeChanged` | `@server.on_volume_changed` | `float` (0–100%) | Fired when volume level changes. |
112
+ | `RepeatChanged` | `@server.on_repeat_changed` | `RepeatMode` | Fired when repeat mode changes (OFF, CONTEXT, TRACK). |
113
+ | `ShuffleChanged` | `@server.on_shuffle_changed` | `bool` | Fired when shuffle mode is toggled. |
114
+ | `SeekChanged` | `@server.on_seek_changed` | `int` (ms) | Fired when timeline position is manually changed. |
115
+ ---
@@ -0,0 +1,86 @@
1
+ [![spicetify-websocket](https://github.com/tobfd/spicetify-websocket/blob/master/docs/_static/logo.png?raw=true)](https://github.com/tobfd/spicetify-websocket)
2
+
3
+ [![PyPI Version](https://img.shields.io/pypi/v/spicetify-websocket?style=for-the-badge&logo=pypi&logoColor=white&color=magenta)](https://pypi.org/project/spicetify-websocket/)
4
+ [![GitHub License](https://img.shields.io/github/license/tobfd/spicetify-websocket?style=for-the-badge&logo=github&color=red)](https://github.com/tobfd/spicetify-websocket/blob/master/LICENSE)
5
+ [![](https://img.shields.io/badge/python-3.10%2B-blue.svg?style=for-the-badge&logo=python&logoColor=white)](https://www.python.org/)
6
+ [![Read the Docs](https://img.shields.io/readthedocs/spicetify-websocket?style=for-the-badge&logo=readthedocs)](https://spicetify-websocket.readthedocs.io/)
7
+
8
+ An asynchronous Python wrapper and WebSocket server for controlling the Spotify desktop client via [Spicetify](https://spicetify.app/) and the [spicetify-connect-api]([https://github.com/tobfd/spicetify-connect-api) extension.
9
+
10
+ ## ✨ Features
11
+
12
+ - ⚡ **Real-time Push Events:** Instant updates for song changes, volume, seeking, and playback state.
13
+ - 🎮 **Full Playback Control:** Play, pause, skip, seek, volume, repeat, and shuffle.
14
+ - 🛠️ **Convenience Decorators:** Easy event listening with syntax like `@server.on_song_changed`.
15
+ - 🏷️ **Fully Typed:** Pydantic V2 models (`TrackInfo`, `PlayerState`, `RepeatMode`).
16
+ - 🔄 **Async & Non-blocking:** Built on `asyncio` and `websockets` for maximum performance.
17
+ ---
18
+
19
+ ## ⚙️ Installation
20
+
21
+ Python 3.10 or higher is required.
22
+
23
+ ```bash
24
+ pip install spicetify-websocket
25
+ ```
26
+
27
+ ---
28
+
29
+ ## 📋 Prerequisites
30
+
31
+ To use this library, ensure you have:
32
+ 1. **Spotify Desktop Client** installed.
33
+ 2. **[Spicetify CLI](https://spicetify.app/)** installed and configured.
34
+ 3. The [spicetify-connect-api]([https://github.com/tobfd/spicetify-connect-api) extension enabled in Spicetify.
35
+
36
+ ---
37
+
38
+ ## 🚀 Example Usage
39
+
40
+ ```python
41
+ import asyncio
42
+ from spicetify import RepeatMode, SpotifyServer, TrackInfo
43
+
44
+
45
+ async def main():
46
+ async with SpotifyServer() as server:
47
+ # Wait until Spicetify client connects
48
+ await server.wait_for_connection()
49
+
50
+ # Playback Controls
51
+ await server.play_url(url="https://open.spotify.com/intl-de/track/55pBIZO1cqoldeqpp5WR7H?si=57cde33a1bd34ac9")
52
+ await server.set_volume(percent=75)
53
+ await server.set_repeat(mode=RepeatMode.TRACK)
54
+
55
+ # Playback State
56
+ current_track: TrackInfo = await server.get_current_track()
57
+ print(current_track)
58
+
59
+ # Events
60
+ @server.on_song_changed
61
+ def callback(track: TrackInfo):
62
+ print("New song is playing:", track.title)
63
+ print("Artist/s:", ", ".join(artist.name for artist in track.artists))
64
+
65
+ # Keep the server running to receive events
66
+ await asyncio.Event().wait()
67
+
68
+
69
+ if __name__ == "__main__":
70
+ asyncio.run(main())
71
+ ```
72
+
73
+ ---
74
+
75
+ ## 📻 Events Reference
76
+
77
+ | Event Name | Convenience Decorator | Callback Payload Type | Description |
78
+ | :--- | :--- | :--- | :--- |
79
+ | `InitialState` | `@server.on_initial_state` | `PlayerState` | Fired immediately when Spicetify connects. |
80
+ | `SongChanged` | `@server.on_song_changed` | `TrackInfo` | Fired when a new track starts playing. |
81
+ | `PlayPauseChanged` | `@server.on_play_pause_changed` | `PlayerState` | Fired when playback state changes. |
82
+ | `VolumeChanged` | `@server.on_volume_changed` | `float` (0–100%) | Fired when volume level changes. |
83
+ | `RepeatChanged` | `@server.on_repeat_changed` | `RepeatMode` | Fired when repeat mode changes (OFF, CONTEXT, TRACK). |
84
+ | `ShuffleChanged` | `@server.on_shuffle_changed` | `bool` | Fired when shuffle mode is toggled. |
85
+ | `SeekChanged` | `@server.on_seek_changed` | `int` (ms) | Fired when timeline position is manually changed. |
86
+ ---
@@ -0,0 +1,66 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "spicetify-websocket"
7
+ authors = [
8
+ { name="Tobias Schmitt", email="support@tobfd.de" },
9
+ ]
10
+ description = "An asynchronous Python wrapper and WebSocket server for controlling the Spotify desktop client via Spicetify and the spicetify-connect-api extension."
11
+ readme = "README.md"
12
+ requires-python = ">=3.10"
13
+ classifiers = [
14
+ "Development Status :: 5 - Production/Stable",
15
+ "Intended Audience :: Developers",
16
+ "Programming Language :: Python :: 3",
17
+ "Programming Language :: Python :: 3.10",
18
+ "Programming Language :: Python :: 3.11",
19
+ "Programming Language :: Python :: 3.12",
20
+ "Programming Language :: Python :: 3.13",
21
+ "Programming Language :: Python :: 3.14",
22
+ "Operating System :: OS Independent",
23
+ "Topic :: Utilities",
24
+ "Topic :: Software Development :: Libraries",
25
+ "Topic :: Software Development :: Libraries :: Python Modules"
26
+ ]
27
+ keywords = ["spicetify", "websocket", "local", "spotify"]
28
+ license = "MIT"
29
+ license-files = ["LICEN[CS]E*"]
30
+ dependencies = [
31
+ "pydantic>=2.13.4,<3.0",
32
+ "websockets>=16.1.1,<17.0",
33
+ ]
34
+ dynamic = ["version"]
35
+
36
+ [project.urls]
37
+ Github = "https://github.com/tobfd/spicetify-websocket"
38
+ Documentation = "https://spicetify-websocket.readthedocs.io"
39
+ Changelog = "https://github.com/tobfd/spicetify-websocket/releases"
40
+
41
+ [tool.setuptools.dynamic]
42
+ version = {attr = "spicetify.__version__"}
43
+
44
+ [tool.ruff]
45
+ line-length = 100
46
+ target-version = "py310"
47
+ fix = true
48
+
49
+ [tool.ruff.lint]
50
+ extend-select = [
51
+ "E", # pycodestyle errors
52
+ "W", # pycodestyle warnings
53
+ "I", # isort (Import sorting)
54
+ "UP", # pyupgrade (Modern Python)
55
+ "B", # flake8-bugbear
56
+ "C4", # flake8-comprehensions
57
+ "RUF", # Ruff-specific rules
58
+ ]
59
+
60
+ [lint.per-file-ignores]
61
+ "examples/*" = ["T201"]
62
+ "tests/*" = ["SLF001", "S101"]
63
+
64
+ [tool.pytest.ini_options]
65
+ addopts = "--cov=spicetify --cov-report=term-missing --cov-report=html"
66
+ asyncio_mode = "auto"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,19 @@
1
+ __title__ = "spicetify-websocket"
2
+ __license__ = "MIT"
3
+ __version__ = "0.1.0"
4
+
5
+ from .exceptions import NotConnectedError, RequestTimeoutError, SpicetifyError
6
+ from .models import ArtistInfo, PlayerState, RepeatMode, TrackInfo
7
+ from .server import SpotifyServer
8
+
9
+ __all__ = [
10
+ "ArtistInfo",
11
+ "NotConnectedError",
12
+ "PlayerState",
13
+ "RepeatMode",
14
+ "RequestTimeoutError",
15
+ "SpicetifyError",
16
+ "SpotifyServer",
17
+ "TrackInfo",
18
+ "__version__",
19
+ ]
@@ -0,0 +1,27 @@
1
+ class SpicetifyError(Exception):
2
+ """Base exception for all errors raised by this library."""
3
+
4
+
5
+ class NotConnectedError(SpicetifyError):
6
+ """Raised when an action is attempted without an active connection.
7
+
8
+ Args:
9
+ message: Human-readable error message.
10
+ """
11
+
12
+ def __init__(self, message="No active connection to Spicetify is available."):
13
+ super().__init__(message)
14
+
15
+
16
+ class RequestTimeoutError(SpicetifyError):
17
+ """Raised when Spotify does not respond to a command in time.
18
+
19
+ Args:
20
+ command: Name of the command that timed out.
21
+ timeout: Timeout value in seconds.
22
+ """
23
+
24
+ def __init__(self, command: str, timeout: float):
25
+ self.command = command
26
+ self.timeout = timeout
27
+ super().__init__(f"Command '{command}' did not respond within {timeout}s.")