Asyncio based SoulSeek client
Project description
aioslsk is a Python library for the SoulSeek protocol built on top of asyncio.
Supported Python versions are currently 3.9 - 3.13
You can find the full documentation here
Installation
pip install aioslsk
Quick Start
Starting the client and sending a private message:
import asyncio
from aioslsk.client import SoulSeekClient
from aioslsk.commands import PrivateMessageCommand
from aioslsk.settings import Settings, CredentialsSettings
# Create default settings and configure credentials
settings: Settings = Settings(
credentials=CredentialsSettings(
username='my_user',
password='Secret123'
)
)
async def main():
client: SoulSeekClient = SoulSeekClient(settings)
await client.start()
await client.login()
# Send a private message
await client.execute(PrivateMessageCommand('my_friend', 'Hi!'))
await client.stop()
asyncio.run(main())
Development
Install poetry and setup the project dependencies by running:
poetry install
A tool is available to start the client for debugging purposes (try out commands to the server, …):
Create a settings.json file containing valid credentials in the tools/debug/ directory (or pass a path using --settings). To generate a simple settings file:
poetry run python -m aioslsk.settings generate -u "Hello" -p "World" > tools/debug/settings.json
To start the REPL run:
# Reads from tools/debug/settings.json poetry run python -m tools.debug.debug_mode # Reads from specific file poetry run python -m tools.debug.debug_mode --settings ~/custom_settings.json
Run an example command (the aioslsk.commands module is aliased to the cmds variable):
await client(cmds.GetPeerAddressCommand('some user'), response=True)
To close the REPL execute exit() or press Ctrl+Z
Optionally the script takes a --cache-dir that will read/write the transfer and shares cache from the given directory
Building the documentation
cd docs/
poetry run make html
Running Tests
Running all tests:
poetry run pytest tests/
Running all tests with code coverage report:
poetry run pytest --cov=aioslsk --cov-report term-missing tests/
Mock Server
A mock server implementation is available for testing, to start the server run:
# By default the server listens on port 2416
poetry run python -m tests.e2e.mock.server
# Specifying multiple listening ports
poetry run python -m tests.e2e.mock.server --port 2416 2242
Configure the hostname or IP of the server in your client and connect. If such configuration is not possible you can add an entry to the hosts file of your system. For example:
127.0.0.1 server.slsknet.org
Use --help to get a list of available options.
Dependencies
The package uses several dependencies:
mutagen : library used for extracting audio metadata
aiofiles : asyncio library for filesystem management
async-upnp-client : library for managing UPnP configuration
pydantic-settings : library for managing settings
async-timeout : library providing timeout class
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file aioslsk-1.4.1.tar.gz
.
File metadata
- Download URL: aioslsk-1.4.1.tar.gz
- Upload date:
- Size: 103.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.10.12 Linux/6.5.0-1025-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e1fa783e4e10953f87846ae2bc0084fea57bf87aa3e45432f063368b981cc9dc |
|
MD5 | 192117e50e53cb4988788d554985e292 |
|
BLAKE2b-256 | d1dfc693f398a714080e860f72655a2152e853c6c99af7077857330f676e2d65 |
File details
Details for the file aioslsk-1.4.1-py3-none-any.whl
.
File metadata
- Download URL: aioslsk-1.4.1-py3-none-any.whl
- Upload date:
- Size: 117.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.10.12 Linux/6.5.0-1025-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b59ece7f04790f6d75402e02290e84d7eabb01d36a58826f6e45516ba1c5408e |
|
MD5 | a3c980544861c9b9fb90bcddca84de95 |
|
BLAKE2b-256 | e27f335865807b870ee28695692ab458f2b9cd22f100c9a99e11e1dc606f1250 |