Skip to main content

A wrapper around Obsidian's REST and Websocket API.

Project description

obsidian.py banner obsidian.py

A wrapper around Obsidian's REST and Websocket API.
View on PyPI or Read the Docs


What is obsidian.py?

A fully object-oriented wrapper around Obsidian v2 designed for discord.py.
This wrapper is based off of Slate.

Requirements

Python (3.7+)

Obsidian (v2)

Features

  • 100% coverage
  • Fully asynchronous
  • Object oriented
  • Playlist support
  • Advanced audio filter support
  • Querying tracks from many sources
  • Spotify support
  • Preset classes
  • Fully typed

Documentation

You can view documentation on the core library here.

Setting up Obsidian & obsidian.py

Downloading Obsidian

First, we must download Obsidian itself.
The JAR located in current Obsidian respoitory is outdated, however the working build can be downloaded here.

Creating obsidian.yml

You must have an obsidian.yml file before running Obsidian.
Create/download the file in the same directory as the JAR file (mentioned above).

Installing obsidian.py

Next, let's install obsidian.py.
You can download it directly from PyPI (Using pip):

$ pip install obsidian.py

Or, if you want early access to new additions for obsidian.py, clone directly from Github:

$ pip install git+https://github.com/jay3332/obsidian.py

Running Obsidian

Make sure you have Java 16 or higher downloaded.

To run Obsidian, cd to the directory the JAR file you downloaded above is located in:

$ cd /path/to/directory

Then, run it using Java's command line tool:

$ cd /path/to/directory

$ java -jar Obsidian.jar 

(Replace Obsidian.jar to the name of the JAR file.)

If successful, you should see many things getting logged into console.

You're all set - now you just have to write code.
See below for examples, or take a look into the examples folder.

Examples

Basic

import discord
import obsidian

from discord.ext import commands


class Bot(commands.Bot):
    def __init__(self, **options):
        super().__init__(**options)
        self.loop.create_task(self.start_obsidian)

    async def start_obsidian(self):
        self.obsidian = await obsidian.initiate_node(bot=self)


bot = Bot(command_prefix='$')

@bot.command()
async def connect(ctx):
    channel = ctx.author.voice.channel
    player = ctx.bot.obsidian.get_player(ctx.guild)
    await player.connect(channel)

@bot.command()
async def play(ctx, *, song: str):
    player = ctx.bot.obsidian.get_player(ctx.guild)
    track = await ctx.bot.obsidian.search_track(song, source=obsidian.Source.YOUTUBE)
    await player.play(track)


if __name__ == '__main__':
    bot.run('TOKEN')

Credits

Changelog

The changelog has been moved to our documentation page.

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

obsidian.py-0.3.0.tar.gz (33.3 kB view hashes)

Uploaded Source

Built Distribution

obsidian.py-0.3.0-py3-none-any.whl (37.9 kB view hashes)

Uploaded Python 3

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