Skip to main content

A Discord voice library using Python Songbird bindings.

Project description

⚠️ This library is on lifeline support and I am looking for a new maintainer. Please DM me if you are interested.

Songbird-Py

Songbird bindings for python. The goal is to provide an easy to use alternitive to Lavalink. Its written with rust-bindings to Songbird.

Songbird-py Docs

Dependencies

This library requires Opus to be installed. ffmpeg functions also require FFmpeg to be installed.

:warning: The static-ffmpeg package on pypi does not work

Building Source Dist

If you are not on windows, macos, or linux x86_64 or need to use a version of python different than 3.8-3.10 you will need to build the source dist. The only change to the installation process is that Rust will need to be installed before installing from pip.

Playing a Song

Once you are connected to a channel, playing music is extremely easy.

from songbird import ytdl

# `voice` was created from a connection to the gateway.

track_handle = await voice.play_source(await ytdl("https://www.youtube.com/watch?v=r25MAkzkTF4"))

await sleep(5)
# Doesn't need to be awaited!
track_handle.pause()
await sleep(5)
track_handle.play()

Supported Libraries

Hikari and Pincer are currently the only supported libraries. See the examples directory for more information.

Using with your own Gateway

from asyncio import run
from songbird import Driver

async def main():
    voice = await Driver.create()
    # `server` is the server payload from the gateway.
    # `state` is the voice state payload from the gateway.
    await voice.connect(
        token=server.token,
        endpoint=server.endpoint,
        session_id=state.session_id,
        guild_id=server.guild_id,
        channel_id=state.channel_id,
        user_id=state.user_id
    )

run(main())

Contributing

Pyo3 asyncio is used with tokio.

Dependencies

Maturin should be installed though pip. This is used to build the Rust code to a python lib. Run command maturin develop when changes are made to the Rust src.

pyo3

pyo3 docs

pyo3 asyncio

pyo3 asyncio docs You can also look at the async secion of the pyo3 docs.

Songbird

Link

docs

Its a good idea to install all the dependencies.

Goal of the project

Create API for songbird driver and everything that is needed with it it.

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

songbird_py-0.1.9.tar.gz (130.2 kB view hashes)

Uploaded Source

Built Distributions

songbird_py-0.1.9-cp310-none-win_amd64.whl (2.6 MB view hashes)

Uploaded CPython 3.10 Windows x86-64

songbird_py-0.1.9-cp310-cp310-manylinux_2_34_x86_64.whl (4.5 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.34+ x86-64

songbird_py-0.1.9-cp310-cp310-macosx_10_9_x86_64.whl (2.8 MB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

songbird_py-0.1.9-cp39-none-win_amd64.whl (2.6 MB view hashes)

Uploaded CPython 3.9 Windows x86-64

songbird_py-0.1.9-cp39-cp39-manylinux_2_34_x86_64.whl (4.5 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.34+ x86-64

songbird_py-0.1.9-cp39-cp39-macosx_10_9_x86_64.whl (2.8 MB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

songbird_py-0.1.9-cp38-none-win_amd64.whl (2.6 MB view hashes)

Uploaded CPython 3.8 Windows x86-64

songbird_py-0.1.9-cp38-cp38-manylinux_2_34_x86_64.whl (4.5 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.34+ x86-64

songbird_py-0.1.9-cp38-cp38-macosx_10_9_x86_64.whl (2.8 MB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

Supported by

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