feat: implement librespot-powered search

This commit is contained in:
Xoconoch
2025-08-26 22:09:07 -06:00
parent c38f10957c
commit 6c795d8d92
3 changed files with 76 additions and 3 deletions

View File

@@ -189,6 +189,24 @@ playlist_expanded = client.get_playlist("spotify:playlist:...", expand_items=Tru
```
### search(query, limit=10, country=None, locale=None, catalogue=None, image_size=None) -> dict
Performs a full-featured search using librespot's SearchManager.
- Country precedence: explicit `country` > session country code > unset
- Returns librespot's JSON-like mapping (tracks, albums, artists, playlists, etc.)
Usage:
```python
res = client.search(
"artist:daft punk track:one more time",
limit=10,
country="US",
locale="en_US"
)
tracks = res.get("tracks", {}).get("items", [])
```
## Concurrency and caching
- When expanding tracks for albums/playlists, the client concurrently fetches missing track objects using a `ThreadPoolExecutor` with up to `max_workers` threads (default 16).