Skip to main content

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.10 - 3.14

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, …):

  1. 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
  2. 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
  3. Run an example command (the aioslsk.commands module is aliased to the cmds variable):

    await client(cmds.GetPeerAddressCommand('some user'), response=True)
  4. 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/

By default the logs are only shown in case of failure. To enable all logging output during testing run the tests as follows:

poetry run pytest tests/ -o log_cli=true

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:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aioslsk-1.6.3.tar.gz (114.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aioslsk-1.6.3-py3-none-any.whl (130.7 kB view details)

Uploaded Python 3

File details

Details for the file aioslsk-1.6.3.tar.gz.

File metadata

  • Download URL: aioslsk-1.6.3.tar.gz
  • Upload date:
  • Size: 114.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.0 CPython/3.12.3 Linux/6.11.0-1018-azure

File hashes

Hashes for aioslsk-1.6.3.tar.gz
Algorithm Hash digest
SHA256 f2f448f7c0869da22a9efbb13aa8cfe44781f793b21787fcd485bcf45763c217
MD5 10a3fb67fb357dc29affea3090ffd292
BLAKE2b-256 de63187db0df09f7ff8d6adeffe26280f48ff466de347dafc361154a77c20d7f

See more details on using hashes here.

File details

Details for the file aioslsk-1.6.3-py3-none-any.whl.

File metadata

  • Download URL: aioslsk-1.6.3-py3-none-any.whl
  • Upload date:
  • Size: 130.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.0 CPython/3.12.3 Linux/6.11.0-1018-azure

File hashes

Hashes for aioslsk-1.6.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0ef2438c496b8c6e3404fbd653ebabba2c8e6082774a0baf8f225f27f304eeee
MD5 f7cce49a2f1c76679e7370e74df720d5
BLAKE2b-256 f6152d129c76f8c82ac21c856fc2a865f728b57cb7ff7c35090382c4cc259a0a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page