waterlink 1.0.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.
Files changed (58) hide show
  1. waterlink-1.0.0/.github/workflows/ci.yml +24 -0
  2. waterlink-1.0.0/.github/workflows/release.yml +20 -0
  3. waterlink-1.0.0/.gitignore +17 -0
  4. waterlink-1.0.0/CHANGELOG.md +41 -0
  5. waterlink-1.0.0/CONTRIBUTING.md +45 -0
  6. waterlink-1.0.0/LICENSE +21 -0
  7. waterlink-1.0.0/PKG-INFO +251 -0
  8. waterlink-1.0.0/README.md +209 -0
  9. waterlink-1.0.0/docs/getting-started.md +42 -0
  10. waterlink-1.0.0/docs/guide/events.md +21 -0
  11. waterlink-1.0.0/docs/guide/filters.md +18 -0
  12. waterlink-1.0.0/docs/guide/metadata-cleaning.md +67 -0
  13. waterlink-1.0.0/docs/guide/nodes.md +22 -0
  14. waterlink-1.0.0/docs/guide/persistence-observability.md +42 -0
  15. waterlink-1.0.0/docs/guide/player.md +34 -0
  16. waterlink-1.0.0/docs/index.md +9 -0
  17. waterlink-1.0.0/examples/advanced_bot.py +130 -0
  18. waterlink-1.0.0/examples/basic_bot.py +77 -0
  19. waterlink-1.0.0/pyproject.toml +80 -0
  20. waterlink-1.0.0/src/waterlink/__init__.py +235 -0
  21. waterlink-1.0.0/src/waterlink/_compat.py +72 -0
  22. waterlink-1.0.0/src/waterlink/_version.py +11 -0
  23. waterlink-1.0.0/src/waterlink/autoplay.py +102 -0
  24. waterlink-1.0.0/src/waterlink/backoff.py +43 -0
  25. waterlink-1.0.0/src/waterlink/cache.py +58 -0
  26. waterlink-1.0.0/src/waterlink/crossfade.py +110 -0
  27. waterlink-1.0.0/src/waterlink/errors.py +194 -0
  28. waterlink-1.0.0/src/waterlink/events.py +248 -0
  29. waterlink-1.0.0/src/waterlink/filters.py +291 -0
  30. waterlink-1.0.0/src/waterlink/formatting.py +75 -0
  31. waterlink-1.0.0/src/waterlink/manager.py +254 -0
  32. waterlink-1.0.0/src/waterlink/metadata.py +373 -0
  33. waterlink-1.0.0/src/waterlink/metrics.py +110 -0
  34. waterlink-1.0.0/src/waterlink/node.py +300 -0
  35. waterlink-1.0.0/src/waterlink/persistence.py +168 -0
  36. waterlink-1.0.0/src/waterlink/player.py +343 -0
  37. waterlink-1.0.0/src/waterlink/plugins.py +106 -0
  38. waterlink-1.0.0/src/waterlink/pool.py +150 -0
  39. waterlink-1.0.0/src/waterlink/py.typed +0 -0
  40. waterlink-1.0.0/src/waterlink/queue.py +200 -0
  41. waterlink-1.0.0/src/waterlink/rest.py +146 -0
  42. waterlink-1.0.0/src/waterlink/search.py +81 -0
  43. waterlink-1.0.0/src/waterlink/tracing.py +67 -0
  44. waterlink-1.0.0/src/waterlink/tracks.py +196 -0
  45. waterlink-1.0.0/src/waterlink/typing.py +20 -0
  46. waterlink-1.0.0/src/waterlink/voice.py +110 -0
  47. waterlink-1.0.0/src/waterlink/watchdog.py +126 -0
  48. waterlink-1.0.0/src/waterlink/websocket.py +180 -0
  49. waterlink-1.0.0/tests/test_backoff.py +31 -0
  50. waterlink-1.0.0/tests/test_cache.py +52 -0
  51. waterlink-1.0.0/tests/test_events.py +85 -0
  52. waterlink-1.0.0/tests/test_filters.py +78 -0
  53. waterlink-1.0.0/tests/test_formatting.py +58 -0
  54. waterlink-1.0.0/tests/test_metadata.py +87 -0
  55. waterlink-1.0.0/tests/test_persistence.py +83 -0
  56. waterlink-1.0.0/tests/test_pool.py +78 -0
  57. waterlink-1.0.0/tests/test_queue.py +106 -0
  58. waterlink-1.0.0/tests/test_tracks_and_search.py +108 -0
@@ -0,0 +1,24 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ python-version: ["3.11", "3.12", "3.13"]
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+ - uses: actions/setup-python@v5
18
+ with:
19
+ python-version: ${{ matrix.python-version }}
20
+ - run: pip install -e ".[dev]"
21
+ - run: ruff check src tests
22
+ - run: ruff format --check src tests
23
+ - run: mypy
24
+ - run: pytest -m "not integration"
@@ -0,0 +1,20 @@
1
+ name: Release
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ jobs:
8
+ publish:
9
+ runs-on: ubuntu-latest
10
+ environment: pypi
11
+ permissions:
12
+ id-token: write
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+ - uses: actions/setup-python@v5
16
+ with:
17
+ python-version: "3.12"
18
+ - run: pip install build
19
+ - run: python -m build
20
+ - uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,17 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.egg-info/
4
+ .eggs/
5
+ build/
6
+ dist/
7
+ .venv/
8
+ venv/
9
+ .env
10
+ .mypy_cache/
11
+ .pytest_cache/
12
+ .ruff_cache/
13
+ .coverage
14
+ htmlcov/
15
+ docs/_build/
16
+ *.log
17
+ .DS_Store
@@ -0,0 +1,41 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented in this file.
4
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
5
+ and this project adheres to [Semantic Versioning](https://semver.org/).
6
+
7
+ ## [Unreleased]
8
+
9
+ ### Added
10
+
11
+ - `waterlink.metadata` module with `TitleCleaner` for cleaning noisy
12
+ YouTube-style track titles/authors (e.g. turning
13
+ `"Tere Liye | Arijit Singh | Viral | T-Series"` uploaded by `"T-Series"`
14
+ into title `"Tere Liye"` by artist `"Arijit Singh"`), plus a
15
+ `clean_track()` convenience function.
16
+ - `WaterlinkClient(clean_metadata=True)` and `client.search(..., clean=True)`
17
+ to opt into automatic metadata cleaning on search results.
18
+ - Recognizes YouTube's auto-generated `"<Artist> - Topic"` and
19
+ `"<Artist>VEVO"` channel naming conventions.
20
+
21
+ ## [1.0.0] - 2026-07-02
22
+
23
+ ### Added
24
+
25
+ - Initial public release of waterlink.
26
+ - Lavalink v4 REST client with session resuming support.
27
+ - Websocket connection handling with automatic exponential-backoff reconnects.
28
+ - `NodePool` with `LOWEST_LOAD`, `ROUND_ROBIN`, and `REGION` routing strategies.
29
+ - Auto-detection of discord.py, py-cord, nextcord, and disnake.
30
+ - `Player` with connect/disconnect, play/pause/resume/stop/skip/seek, and volume control.
31
+ - `Queue` with history, shuffle, deduplication, and track/queue loop modes.
32
+ - Typed `FilterChain` covering equalizer, karaoke, timescale, tremolo, vibrato,
33
+ rotation, distortion, channel mix, and low-pass filters.
34
+ - `AutoplayEngine` with a pluggable related-track strategy.
35
+ - `CrossfadeController` for client-side volume-ramped track transitions.
36
+ - State persistence via `PlayerSnapshot` with `JSONFileBackend` and `InMemoryBackend`.
37
+ - `PluginRegistry` plus `LavaSrcHelper` and `SponsorBlockHelper` convenience wrappers.
38
+ - `MetricsCollector` with Prometheus text export, and a `Watchdog` for detecting
39
+ stalled players and stale nodes.
40
+ - Structured, context-aware logging via `configure_logging` / `get_logger`.
41
+ - Full type hints and a `py.typed` marker.
@@ -0,0 +1,45 @@
1
+ # Contributing to waterlink
2
+
3
+ Thanks for considering a contribution! A few guidelines to keep things smooth:
4
+
5
+ ## Development setup
6
+
7
+ ```bash
8
+ git clone https://github.com/yup-console/waterlink
9
+ cd waterlink
10
+ python -m venv .venv && source .venv/bin/activate
11
+ pip install -e ".[dev]"
12
+ ```
13
+
14
+ ## Running checks
15
+
16
+ ```bash
17
+ ruff check src tests
18
+ ruff format --check src tests
19
+ mypy
20
+ pytest
21
+ ```
22
+
23
+ Integration tests that need a live Lavalink server are marked
24
+ `@pytest.mark.integration` and skipped by default; run them with
25
+ `pytest -m integration` against a local server.
26
+
27
+ ## Style
28
+
29
+ - Full type hints on all public APIs; `mypy --strict` must pass.
30
+ - Prefer small, focused modules over large "god objects."
31
+ - Public API changes should be reflected in `CHANGELOG.md` under an
32
+ `[Unreleased]` heading.
33
+ - Docstrings follow the existing module style (short summary + relevant
34
+ detail, no framework-specific autodoc syntax required).
35
+
36
+ ## Commit / PR conventions
37
+
38
+ - Keep PRs scoped to one change where possible.
39
+ - Add or update tests for behavioral changes.
40
+ - Describe *why* a change is made, not just *what* changed.
41
+
42
+ ## Reporting issues
43
+
44
+ Please include: waterlink version, Lavalink version, Discord library +
45
+ version, a minimal reproduction, and the full traceback if applicable.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 waterlink contributors
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,251 @@
1
+ Metadata-Version: 2.4
2
+ Name: waterlink
3
+ Version: 1.0.0
4
+ Summary: A modern, async, fully-typed Lavalink v4 client for Python Discord bots.
5
+ Project-URL: Homepage, https://github.com/yup-console/waterlink
6
+ Project-URL: Repository, https://github.com/yup-console/waterlink
7
+ Project-URL: Issues, https://github.com/yup-console/waterlink/issues
8
+ Project-URL: Changelog, https://github.com/yup-console/waterlink/blob/main/CHANGELOG.md
9
+ Author: waterlink contributors
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Keywords: asyncio,bot,discord,lavalink,music,voice
13
+ Classifier: Development Status :: 5 - Production/Stable
14
+ Classifier: Framework :: AsyncIO
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Communications :: Chat
23
+ Classifier: Topic :: Multimedia :: Sound/Audio
24
+ Classifier: Typing :: Typed
25
+ Requires-Python: >=3.11
26
+ Requires-Dist: aiohttp<4,>=3.9
27
+ Provides-Extra: dev
28
+ Requires-Dist: discord-py<3,>=2.4; extra == 'dev'
29
+ Requires-Dist: mypy>=1.13; extra == 'dev'
30
+ Requires-Dist: pytest-asyncio>=0.24; extra == 'dev'
31
+ Requires-Dist: pytest>=8.3; extra == 'dev'
32
+ Requires-Dist: ruff>=0.8; extra == 'dev'
33
+ Provides-Extra: discordpy
34
+ Requires-Dist: discord-py<3,>=2.4; extra == 'discordpy'
35
+ Provides-Extra: disnake
36
+ Requires-Dist: disnake<3,>=2.9; extra == 'disnake'
37
+ Provides-Extra: nextcord
38
+ Requires-Dist: nextcord<3,>=2.6; extra == 'nextcord'
39
+ Provides-Extra: pycord
40
+ Requires-Dist: py-cord<3,>=2.4; extra == 'pycord'
41
+ Description-Content-Type: text/markdown
42
+
43
+ # waterlink
44
+
45
+ **A modern, fully-typed, async Lavalink v4 client for Python Discord bots.**
46
+
47
+ waterlink wraps Lavalink's REST and websocket protocol behind a clean,
48
+ Pythonic API: node pooling with load-aware routing, a rich queue engine,
49
+ typed audio filters, autoplay, crossfade, state persistence across
50
+ restarts, and helpers for popular Lavalink plugins — all with full type
51
+ hints and zero required dependencies beyond `aiohttp`.
52
+
53
+ It auto-detects whichever Discord library you're already using —
54
+ **discord.py**, **py-cord**, **nextcord**, or **disnake** — so you don't
55
+ install anything extra for voice support.
56
+
57
+ [![PyPI](https://img.shields.io/pypi/v/waterlink)](https://pypi.org/project/waterlink/)
58
+ [![Python](https://img.shields.io/pypi/pyversions/waterlink)](https://pypi.org/project/waterlink/)
59
+ [![License](https://img.shields.io/badge/license-MIT-blue)](LICENSE)
60
+ [![GitHub](https://img.shields.io/badge/github-yup--console%2Fwaterlink-black)](https://github.com/yup-console/waterlink)
61
+
62
+ ---
63
+
64
+ ## Features
65
+
66
+ - **Lavalink v4 native** — REST + websocket built against the current protocol, including session resuming.
67
+ - **Multi-node pooling** with pluggable routing strategies (lowest load, round robin, region-aware).
68
+ - **Multi-library support** — auto-detects discord.py, py-cord, nextcord, or disnake.
69
+ - **Rich queue engine** — history, shuffle, dedupe, track/queue loop modes, priority insertion.
70
+ - **Typed audio filters** — equalizer, timescale, karaoke, tremolo, vibrato, rotation, distortion, channel mix, low-pass, all validated.
71
+ - **Autoplay** — keeps audio flowing with a pluggable "related track" strategy once the queue empties.
72
+ - **Clean metadata** — turns noisy YouTube-style results like `"Tere Liye | Arijit Singh | Viral | T-Series"` by `"T-Series"` into title `"Tere Liye"` by artist `"Arijit Singh"`, opt-in per client or per search call.
73
+ - **Crossfade** — smooth client-side volume ramping across track transitions.
74
+ - **State persistence** — snapshot and restore queues/players across bot restarts (JSON file backend included, or bring your own).
75
+ - **Plugin helpers** — typed convenience wrappers for LavaSrc and SponsorBlock.
76
+ - **Observability** — structured logging, an in-process metrics collector (with Prometheus text export), and a watchdog for stalled playback/stale nodes.
77
+ - **Fully typed** — ships a `py.typed` marker; passes `mypy --strict`.
78
+
79
+ ## Installation
80
+
81
+ ```bash
82
+ pip install waterlink[discordpy]
83
+ # or: waterlink[pycord] / waterlink[nextcord] / waterlink[disnake]
84
+ ```
85
+
86
+ waterlink only requires `aiohttp` itself — the extras above just also
87
+ install a supported Discord library if you don't already have one.
88
+
89
+ You'll also need a running [Lavalink](https://github.com/lavalink-devs/Lavalink)
90
+ v4 server.
91
+
92
+ ## Quick start
93
+
94
+ ```python
95
+ import discord
96
+ from discord.ext import commands
97
+ import waterlink
98
+
99
+ intents = discord.Intents.default()
100
+ bot = commands.Bot(command_prefix="!", intents=intents)
101
+ client: waterlink.WaterlinkClient | None = None
102
+
103
+ @bot.event
104
+ async def on_ready():
105
+ global client
106
+ client = waterlink.WaterlinkClient(bot=bot)
107
+ await client.add_node(host="localhost", port=2333, password="youshallnotpass")
108
+ print(f"waterlink ready, using {client.library_name}")
109
+
110
+ @bot.command()
111
+ async def play(ctx: commands.Context, *, query: str):
112
+ if ctx.author.voice is None:
113
+ return await ctx.send("Join a voice channel first.")
114
+
115
+ player = await client.connect(ctx.guild.id, ctx.author.voice.channel.id)
116
+
117
+ result = await client.search(query)
118
+ if isinstance(result, waterlink.TrackResult):
119
+ track = result.track
120
+ elif isinstance(result, waterlink.SearchTracksResult) and result.tracks:
121
+ track = result.tracks[0]
122
+ else:
123
+ return await ctx.send("No results found.")
124
+
125
+ await player.enqueue(track.with_requester(ctx.author.id))
126
+ await ctx.send(f"Queued **{track.title}**")
127
+
128
+ bot.run("YOUR_TOKEN")
129
+ ```
130
+
131
+ See [`examples/`](examples/) for a fuller bot with queue management,
132
+ filters, autoplay, and persistence wired up.
133
+
134
+ ## Core concepts
135
+
136
+ ### Node pool
137
+
138
+ ```python
139
+ node = await client.add_node(
140
+ name="main",
141
+ host="lavalink.example.com",
142
+ port=443,
143
+ password="secret",
144
+ secure=True,
145
+ region="us-east",
146
+ )
147
+ ```
148
+
149
+ Add as many nodes as you like; `client.connect()` picks the best one
150
+ automatically (`RoutingStrategy.LOWEST_LOAD` by default).
151
+
152
+ ### Queue & playback
153
+
154
+ ```python
155
+ player = client.get_player(guild_id)
156
+ await player.enqueue(track)
157
+ await player.skip()
158
+ await player.pause()
159
+ await player.resume()
160
+ await player.seek(30_000)
161
+ player.set_loop_mode(waterlink.LoopMode.QUEUE)
162
+ ```
163
+
164
+ ### Filters
165
+
166
+ ```python
167
+ chain = waterlink.FilterChain()
168
+ chain.set_timescale(waterlink.Timescale(speed=1.25, pitch=1.1))
169
+ chain.set_equalizer(waterlink.Equalizer.bass_boost())
170
+ await player.set_filters(chain)
171
+ ```
172
+
173
+ ### Autoplay
174
+
175
+ ```python
176
+ autoplay = waterlink.AutoplayEngine(client.events)
177
+ autoplay.enable(guild_id)
178
+ ```
179
+
180
+ ### Clean metadata
181
+
182
+ YouTube search results are often uploaded by a label, not the artist —
183
+ so `track.title` and `track.author` can come back as
184
+ `"Tere Liye | Arijit Singh | Viral | T-Series"` / `"T-Series"` instead of
185
+ `"Tere Liye"` / `"Arijit Singh"`. Enable automatic cleanup:
186
+
187
+ ```python
188
+ client = waterlink.WaterlinkClient(bot=bot, clean_metadata=True)
189
+ # or per call:
190
+ result = await client.search(query, clean=True)
191
+ ```
192
+
193
+ ```python
194
+ track = result.tracks[0]
195
+ print(track.title) # "Tere Liye"
196
+ print(track.author) # "Arijit Singh"
197
+ print(track.extra["raw_title"]) # original, untouched, if you need it
198
+ print(track.extra["raw_author"])
199
+ ```
200
+
201
+ You can also clean a single track directly, or add your own label names
202
+ (useful for regional labels not already in the default list):
203
+
204
+ ```python
205
+ cleaned = waterlink.clean_track(track)
206
+
207
+ cleaner = waterlink.TitleCleaner(extra_label_names=("my regional label",))
208
+ cleaned = cleaner.clean_track(track)
209
+ ```
210
+
211
+ ### Events
212
+
213
+ ```python
214
+ @client.events.on(waterlink.TrackStartEvent)
215
+ async def on_track_start(event: waterlink.TrackStartEvent):
216
+ print(f"Now playing {event.track.title} in guild {event.player.guild_id}")
217
+ ```
218
+
219
+ ### Persistence
220
+
221
+ ```python
222
+ backend = waterlink.JSONFileBackend("state/")
223
+ snapshot = waterlink.PlayerSnapshot.capture(player)
224
+ await backend.save(snapshot)
225
+ ```
226
+
227
+ ## Documentation
228
+
229
+ Full API reference and guides live in [`docs/`](docs/). Highlights:
230
+
231
+ - [Getting started](docs/getting-started.md)
232
+ - [Player & queue](docs/guide/player.md)
233
+ - [Filters](docs/guide/filters.md)
234
+ - [Nodes & pooling](docs/guide/nodes.md)
235
+ - [Events](docs/guide/events.md)
236
+ - [Persistence & observability](docs/guide/persistence-observability.md)
237
+
238
+ ## Contributing
239
+
240
+ Contributions are welcome — see [CONTRIBUTING.md](CONTRIBUTING.md).
241
+
242
+ ```bash
243
+ git clone https://github.com/yup-console/waterlink
244
+ cd waterlink
245
+ pip install -e ".[dev]"
246
+ pytest
247
+ ```
248
+
249
+ ## License
250
+
251
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,209 @@
1
+ # waterlink
2
+
3
+ **A modern, fully-typed, async Lavalink v4 client for Python Discord bots.**
4
+
5
+ waterlink wraps Lavalink's REST and websocket protocol behind a clean,
6
+ Pythonic API: node pooling with load-aware routing, a rich queue engine,
7
+ typed audio filters, autoplay, crossfade, state persistence across
8
+ restarts, and helpers for popular Lavalink plugins — all with full type
9
+ hints and zero required dependencies beyond `aiohttp`.
10
+
11
+ It auto-detects whichever Discord library you're already using —
12
+ **discord.py**, **py-cord**, **nextcord**, or **disnake** — so you don't
13
+ install anything extra for voice support.
14
+
15
+ [![PyPI](https://img.shields.io/pypi/v/waterlink)](https://pypi.org/project/waterlink/)
16
+ [![Python](https://img.shields.io/pypi/pyversions/waterlink)](https://pypi.org/project/waterlink/)
17
+ [![License](https://img.shields.io/badge/license-MIT-blue)](LICENSE)
18
+ [![GitHub](https://img.shields.io/badge/github-yup--console%2Fwaterlink-black)](https://github.com/yup-console/waterlink)
19
+
20
+ ---
21
+
22
+ ## Features
23
+
24
+ - **Lavalink v4 native** — REST + websocket built against the current protocol, including session resuming.
25
+ - **Multi-node pooling** with pluggable routing strategies (lowest load, round robin, region-aware).
26
+ - **Multi-library support** — auto-detects discord.py, py-cord, nextcord, or disnake.
27
+ - **Rich queue engine** — history, shuffle, dedupe, track/queue loop modes, priority insertion.
28
+ - **Typed audio filters** — equalizer, timescale, karaoke, tremolo, vibrato, rotation, distortion, channel mix, low-pass, all validated.
29
+ - **Autoplay** — keeps audio flowing with a pluggable "related track" strategy once the queue empties.
30
+ - **Clean metadata** — turns noisy YouTube-style results like `"Tere Liye | Arijit Singh | Viral | T-Series"` by `"T-Series"` into title `"Tere Liye"` by artist `"Arijit Singh"`, opt-in per client or per search call.
31
+ - **Crossfade** — smooth client-side volume ramping across track transitions.
32
+ - **State persistence** — snapshot and restore queues/players across bot restarts (JSON file backend included, or bring your own).
33
+ - **Plugin helpers** — typed convenience wrappers for LavaSrc and SponsorBlock.
34
+ - **Observability** — structured logging, an in-process metrics collector (with Prometheus text export), and a watchdog for stalled playback/stale nodes.
35
+ - **Fully typed** — ships a `py.typed` marker; passes `mypy --strict`.
36
+
37
+ ## Installation
38
+
39
+ ```bash
40
+ pip install waterlink[discordpy]
41
+ # or: waterlink[pycord] / waterlink[nextcord] / waterlink[disnake]
42
+ ```
43
+
44
+ waterlink only requires `aiohttp` itself — the extras above just also
45
+ install a supported Discord library if you don't already have one.
46
+
47
+ You'll also need a running [Lavalink](https://github.com/lavalink-devs/Lavalink)
48
+ v4 server.
49
+
50
+ ## Quick start
51
+
52
+ ```python
53
+ import discord
54
+ from discord.ext import commands
55
+ import waterlink
56
+
57
+ intents = discord.Intents.default()
58
+ bot = commands.Bot(command_prefix="!", intents=intents)
59
+ client: waterlink.WaterlinkClient | None = None
60
+
61
+ @bot.event
62
+ async def on_ready():
63
+ global client
64
+ client = waterlink.WaterlinkClient(bot=bot)
65
+ await client.add_node(host="localhost", port=2333, password="youshallnotpass")
66
+ print(f"waterlink ready, using {client.library_name}")
67
+
68
+ @bot.command()
69
+ async def play(ctx: commands.Context, *, query: str):
70
+ if ctx.author.voice is None:
71
+ return await ctx.send("Join a voice channel first.")
72
+
73
+ player = await client.connect(ctx.guild.id, ctx.author.voice.channel.id)
74
+
75
+ result = await client.search(query)
76
+ if isinstance(result, waterlink.TrackResult):
77
+ track = result.track
78
+ elif isinstance(result, waterlink.SearchTracksResult) and result.tracks:
79
+ track = result.tracks[0]
80
+ else:
81
+ return await ctx.send("No results found.")
82
+
83
+ await player.enqueue(track.with_requester(ctx.author.id))
84
+ await ctx.send(f"Queued **{track.title}**")
85
+
86
+ bot.run("YOUR_TOKEN")
87
+ ```
88
+
89
+ See [`examples/`](examples/) for a fuller bot with queue management,
90
+ filters, autoplay, and persistence wired up.
91
+
92
+ ## Core concepts
93
+
94
+ ### Node pool
95
+
96
+ ```python
97
+ node = await client.add_node(
98
+ name="main",
99
+ host="lavalink.example.com",
100
+ port=443,
101
+ password="secret",
102
+ secure=True,
103
+ region="us-east",
104
+ )
105
+ ```
106
+
107
+ Add as many nodes as you like; `client.connect()` picks the best one
108
+ automatically (`RoutingStrategy.LOWEST_LOAD` by default).
109
+
110
+ ### Queue & playback
111
+
112
+ ```python
113
+ player = client.get_player(guild_id)
114
+ await player.enqueue(track)
115
+ await player.skip()
116
+ await player.pause()
117
+ await player.resume()
118
+ await player.seek(30_000)
119
+ player.set_loop_mode(waterlink.LoopMode.QUEUE)
120
+ ```
121
+
122
+ ### Filters
123
+
124
+ ```python
125
+ chain = waterlink.FilterChain()
126
+ chain.set_timescale(waterlink.Timescale(speed=1.25, pitch=1.1))
127
+ chain.set_equalizer(waterlink.Equalizer.bass_boost())
128
+ await player.set_filters(chain)
129
+ ```
130
+
131
+ ### Autoplay
132
+
133
+ ```python
134
+ autoplay = waterlink.AutoplayEngine(client.events)
135
+ autoplay.enable(guild_id)
136
+ ```
137
+
138
+ ### Clean metadata
139
+
140
+ YouTube search results are often uploaded by a label, not the artist —
141
+ so `track.title` and `track.author` can come back as
142
+ `"Tere Liye | Arijit Singh | Viral | T-Series"` / `"T-Series"` instead of
143
+ `"Tere Liye"` / `"Arijit Singh"`. Enable automatic cleanup:
144
+
145
+ ```python
146
+ client = waterlink.WaterlinkClient(bot=bot, clean_metadata=True)
147
+ # or per call:
148
+ result = await client.search(query, clean=True)
149
+ ```
150
+
151
+ ```python
152
+ track = result.tracks[0]
153
+ print(track.title) # "Tere Liye"
154
+ print(track.author) # "Arijit Singh"
155
+ print(track.extra["raw_title"]) # original, untouched, if you need it
156
+ print(track.extra["raw_author"])
157
+ ```
158
+
159
+ You can also clean a single track directly, or add your own label names
160
+ (useful for regional labels not already in the default list):
161
+
162
+ ```python
163
+ cleaned = waterlink.clean_track(track)
164
+
165
+ cleaner = waterlink.TitleCleaner(extra_label_names=("my regional label",))
166
+ cleaned = cleaner.clean_track(track)
167
+ ```
168
+
169
+ ### Events
170
+
171
+ ```python
172
+ @client.events.on(waterlink.TrackStartEvent)
173
+ async def on_track_start(event: waterlink.TrackStartEvent):
174
+ print(f"Now playing {event.track.title} in guild {event.player.guild_id}")
175
+ ```
176
+
177
+ ### Persistence
178
+
179
+ ```python
180
+ backend = waterlink.JSONFileBackend("state/")
181
+ snapshot = waterlink.PlayerSnapshot.capture(player)
182
+ await backend.save(snapshot)
183
+ ```
184
+
185
+ ## Documentation
186
+
187
+ Full API reference and guides live in [`docs/`](docs/). Highlights:
188
+
189
+ - [Getting started](docs/getting-started.md)
190
+ - [Player & queue](docs/guide/player.md)
191
+ - [Filters](docs/guide/filters.md)
192
+ - [Nodes & pooling](docs/guide/nodes.md)
193
+ - [Events](docs/guide/events.md)
194
+ - [Persistence & observability](docs/guide/persistence-observability.md)
195
+
196
+ ## Contributing
197
+
198
+ Contributions are welcome — see [CONTRIBUTING.md](CONTRIBUTING.md).
199
+
200
+ ```bash
201
+ git clone https://github.com/yup-console/waterlink
202
+ cd waterlink
203
+ pip install -e ".[dev]"
204
+ pytest
205
+ ```
206
+
207
+ ## License
208
+
209
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,42 @@
1
+ # Getting Started
2
+
3
+ ## Prerequisites
4
+
5
+ - Python 3.11+
6
+ - A running [Lavalink](https://github.com/lavalink-devs/Lavalink) v4 server
7
+ - A Discord bot using discord.py, py-cord, nextcord, or disnake
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ pip install waterlink[discordpy]
13
+ ```
14
+
15
+ ## Minimal bot
16
+
17
+ ```python
18
+ import discord
19
+ from discord.ext import commands
20
+ import waterlink
21
+
22
+ bot = commands.Bot(command_prefix="!", intents=discord.Intents.default())
23
+ client: waterlink.WaterlinkClient | None = None
24
+
25
+ @bot.event
26
+ async def on_ready():
27
+ global client
28
+ client = waterlink.WaterlinkClient(bot=bot)
29
+ await client.add_node(host="localhost", port=2333, password="youshallnotpass")
30
+
31
+ @bot.command()
32
+ async def play(ctx, *, query: str):
33
+ player = await client.connect(ctx.guild.id, ctx.author.voice.channel.id)
34
+ result = await client.search(query)
35
+ track = result.track if isinstance(result, waterlink.TrackResult) else result.tracks[0]
36
+ await player.enqueue(track)
37
+
38
+ bot.run("TOKEN")
39
+ ```
40
+
41
+ That's the whole setup. See the `docs/guide/` folder for queue management,
42
+ filters, events, persistence, and plugin usage.