pylav.storage.models package#

Subpackages#

Submodules#

pylav.storage.models.config module#

class pylav.storage.models.config.Config(*args: 'Any', **kwargs: 'Any')[source]#

Bases: CachedModel

bot#
async delete()[source]#

Delete the config from the database

async exists()[source]#

Check if the config exists.

Returns:

Whether the config exists.

Return type:

bool

async fetch_all()[source]#

Update all attributed for the config from the database.

Returns:

The updated config.

Return type:

Config

async fetch_auto_update_managed_nodes()[source]#

Fetch the auto_update_managed_nodes.

Returns:

The auto_update_managed_nodes.

Return type:

bool

async fetch_config_folder()[source]#

Fetch the config folder.

Returns:

The config folder.

Return type:

str

async fetch_download_id()[source]#

Fetch the download_id.

Returns:

The download_id.

Return type:

str

async fetch_enable_managed_node()[source]#

Fetch the enable_managed_node.

Returns:

The enable_managed_node.

Return type:

bool

async fetch_extras()[source]#

Fetch the extras.

Returns:

The extras.

Return type:

dict

async fetch_java_path()[source]#

Fetch the java path.

Returns:

The java path.

Return type:

str

async fetch_localtrack_folder()[source]#

Fetch the localtrack folder.

Returns:

The localtrack folder.

Return type:

str

async fetch_next_execution_update_bundled_external_playlists()[source]#

Fetch the next_execution_update_bundled_external_playlists.

Returns:

The next_execution_update_bundled_external_playlists.

Return type:

datetime.datetime

async fetch_next_execution_update_bundled_playlists()[source]#

Fetch the next_execution_update_bundled_playlists.

Returns:

The next_execution_update_bundled_playlists.

Return type:

datetime.datetime

async fetch_next_execution_update_external_playlists()[source]#

Fetch the next_execution_update_external_playlists.

Returns:

The next_execution_update_external_playlists.

Return type:

datetime.datetime

async fetch_update_bot_activity()[source]#

Fetch the update_bot_activity.

Returns:

The update_bot_activity.

Return type:

bool

Fetch the use_bundled_lava_link_external.

Returns:

The use_bundled_lava_link_external.

Return type:

bool

async fetch_use_bundled_pylav_external()[source]#

Fetch the use_bundled_pylav_external.

Returns:

The use_bundled_pylav_external.

Return type:

bool

get_cache_key()[source]#
id#
async update_auto_update_managed_nodes(auto_update_managed_nodes)[source]#

Update the auto_update_managed_nodes.

Parameters:

auto_update_managed_nodes – The new auto_update_managed_nodes.

async update_config_folder(config_folder)[source]#

Update the config folder.

Parameters:

config_folder – The new config folder.

async update_download_id(download_id)[source]#

Update the download_id.

Parameters:

download_id – The new download_id.

async update_enable_managed_node(enable_managed_node)[source]#

Update the enable_managed_node.

Parameters:

enable_managed_node – The new enable_managed_node.

async update_extras(extras)[source]#

Update the extras.

Parameters:

extras – The new extras.

async update_java_path(java_path)[source]#

Update the java path.

Parameters:

java_path – The new java path.

async update_localtrack_folder(localtrack_folder)[source]#

Update the localtrack folder.

Parameters:

localtrack_folder – The new localtrack folder.

async update_next_execution_update_bundled_external_playlists(next_execution)[source]#

Update the next_execution_update_bundled_external_playlists.

Parameters:

next_execution – The new next_execution.

async update_next_execution_update_bundled_playlists(next_execution)[source]#

Update the next_execution_update_bundled_playlists.

Parameters:

next_execution – The new next_execution_update_bundled_playlists.

async update_next_execution_update_external_playlists(next_execution)[source]#

Update the next_execution_update_external_playlists.

Parameters:

next_execution – The new next_execution.

async update_update_bot_activity(update_bot_activity)[source]#

Update the update_bot_activity.

Parameters:

update_bot_activity – The new update_bot_activity.

Update the use_bundled_lava_link_external.

Parameters:

use_bundled_lava_link_external – The new use_bundled_lava_link_external.

async update_use_bundled_pylav_external(use_bundled_pylav_external)[source]#

Update the use_bundled_pylav_external.

Parameters:

use_bundled_pylav_external – The new use_bundled_pylav_external.

pylav.storage.models.equilizer module#

class pylav.storage.models.equilizer.Equalizer(*, id: 'int', scope: 'int', author: 'int', name: 'str | None' = None, description: 'str | None' = None, band_25: 'float | None' = None, band_40: 'float | None' = None, band_63: 'float | None' = None, band_100: 'float | None' = None, band_160: 'float | None' = None, band_250: 'float | None' = None, band_400: 'float | None' = None, band_630: 'float | None' = None, band_1000: 'float | None' = None, band_1600: 'float | None' = None, band_2500: 'float | None' = None, band_4000: 'float | None' = None, band_6300: 'float | None' = None, band_10000: 'float | None' = None, band_16000: 'float | None' = None)[source]#

Bases: CachedModel

author#
band_100#
band_1000#
band_10000#
band_160#
band_1600#
band_16000#
band_25#
band_250#
band_2500#
band_40#
band_400#
band_4000#
band_63#
band_630#
band_6300#
async can_manage(bot, requester)[source]#

Check if the requester can manage the equalizer.

Parameters:
  • bot (DISCORD_BOT_TYPE) – The bot.

  • requester (discord.abc.User) – The requester.

Returns:

If the requester can manage the equalizer.

Return type:

bool

async delete()[source]#

Delete the equalizer from the database

description#
classmethod from_dict(data)[source]#

Deserialize a Equalizer from a dict.

Parameters:

data (dict) – The data to use to build the Equalizer

Returns:

The Equalizer

Return type:

Equalizer

classmethod from_filter(equalizer, context, scope, description=None)[source]#

Deserialize a Equalizer from a Filter.

Parameters:
  • equalizer (Equalizer) – The filter object

  • context (PyLavContext) – The Context

  • scope (int) – The scope number

  • description (str) – The description of the Equalizer

Returns:

The Equalizer built from the Equalizer object

Return type:

Equalizer

async classmethod from_yaml(context, scope, url)[source]#

Deserialize a Equalizer from a YAML file.

Parameters:
  • context (PyLavContext) – The context.

  • scope (int) – The scope.

  • url (str) – The URL to the YAML file.

Returns:

The Equalizer.

Return type:

Equalizer

async classmethod get(identifier)[source]#

Get an equalizer from the database.

Parameters:

identifier (int) – The id of the equalizer.

Returns:

The equalizer if found, else None.

Return type:

Equalizer | None

async get_author_name(bot, mention=True)[source]#

Get the name of the author.

Parameters:
  • bot (DISCORD_BOT_TYPE) – The bot.

  • mention (bool) – If the name should be mentionable.

Returns:

The name of the author.

Return type:

str | None

get_cache_key()[source]#
async get_scope_name(bot, mention=True, guild=None)[source]#

Get the name of the scope.

Parameters:
  • bot (DISCORD_BOT_TYPE) – The bot.

  • mention (bool) – If the name should be mentionable.

  • guild (discord.Guild | None) – The guild.

Returns:

The name of the scope.

Return type:

str

id#
name#
async save()[source]#

Save the Equalizer to the database.

Returns:

The Equalizer.

Return type:

Equalizer

scope#
to_dict()[source]#

Serialize the Equalizer to a dict.

Returns:

The dict representation of the Equalizer.

Return type:

dict

to_filter()[source]#

Serialize the Equalizer to a Filter.

Returns:

The filter representation of the Equalizer

Return type:

Equalizer

to_yaml(guild)[source]#

Serialize the Equalizer to a YAML file.

yields a tuple of (io.BytesIO, bool) where the bool is whether the playlist file was compressed using Gzip

Parameters:

guild (discord.Guild) – The guild.

Yields:

tuple[io.BytesIO, str | None] – The YAML file and the compression type.

pylav.storage.models.playlist module#

class pylav.storage.models.playlist.Playlist(*args: 'Any', **kwargs: 'Any')[source]#

Bases: CachedModel

async add_track(tracks)[source]#

Add a track to the playlist.

Parameters:

tracks (list[str | Track]) – The tracks to add.

async bulk_remove_tracks(tracks)[source]#

Remove disc jockey users from the player.

Parameters:

tracks (list[str]) – The track to remove

async bulk_update(scope, name, author, url, tracks)[source]#

Bulk update the playlist.

async can_manage(bot, requester)[source]#

Check if the requester can manage the playlist.

Parameters:
  • bot (DISCORD_BOT_TYPE) – The bot instance.

  • requester (discord.abc.User) – The requester.

Returns:

Whether the requester can manage the playlist.

Return type:

bool

async delete()[source]#

Delete the playlist from the database

async exists()[source]#

Check if the config exists.

Returns:

Whether the config exists.

Return type:

bool

async fetch_all()[source]#

Fetch all playlists from the database.

Returns:

The playlists.

Return type:

dict

async fetch_author()[source]#

Fetch the author of the playlist.

Returns:

The author of the playlist.

Return type:

int

async fetch_first()[source]#

Get the first track.

Returns:

The first track

Return type:

str

async fetch_index(index)[source]#

Get the track at the index.

Parameters:

index (int) – The index of the track

Returns:

The track at the index

Return type:

str

async fetch_name()[source]#

Fetch the name of the playlist.

Returns:

The name of the playlist.

Return type:

str

async fetch_random()[source]#

Get a random track.

Returns:

A random track

Return type:

str

async fetch_scope()[source]#

Fetch the scope of the playlist.

Returns:

The scope of the playlist.

Return type:

int

async fetch_tracks()[source]#

Fetch the tracks of the playlist.

Returns:

The tracks of the playlist.

Return type:

list[str]

async fetch_url()[source]#

Fetch the url of the playlist.

Returns:

The url of the playlist.

Return type:

str

async classmethod from_yaml(context, scope, url)[source]#

Deserialize a playlist from a YAML file.

Parameters:
  • context (PyLavContext) – The context.

  • scope (int) – The scope of the playlist.

  • url (str) – The url of the playlist.

Returns:

The playlist.

Return type:

Playlist

async get_author_name(bot, mention=True)[source]#

Get the name of the author of the playlist.

Parameters:
  • bot (DISCORD_BOT_TYPE) – The bot instance.

  • mention (bool) – Whether to add a mention if it is mentionable.

Returns:

The name of the author of the playlist.

Return type:

str | None

get_cache_key()[source]#
async get_name_formatted(with_url=True, escape=True)[source]#

Get the name of the playlist formatted.

Parameters:
  • with_url (bool) – Whether to include the url in the name.

  • escape (bool) – Whether to markdown escape the response

Returns:

The formatted name.

Return type:

str

async get_scope_name(bot, mention=True, guild=None)[source]#

Get the name of the scope of the playlist.

Parameters:
  • bot (DISCORD_BOT_TYPE) – The bot instance.

  • mention (bool) – Whether to add a mention if it is mentionable.

  • guild (discord.Guild) – The guild to get the scope name for.

Returns:

The name of the scope of the playlist.

Return type:

str

id#
async remove_all_tracks()[source]#

Remove all tracks from the playlist.

async remove_track(track)[source]#

Remove a track from the playlist.

Parameters:

track (str) – The track to remove

async size()[source]#

Count the tracks of the playlist.

Returns:

The number of tracks in the playlist.

Return type:

int

to_yaml(guild)[source]#

Serialize the playlist to a YAML file.

yields a tuple of (io.BytesIO, bool) where the bool is whether the playlist file was compressed using Gzip

Parameters:

guild (discord.Guild) – The guild where the yaml will be sent to.

Yields:

tuple[io.BytesIO, str | None] – The YAML file and the compression type.

async update_author(author)[source]#

Update the author of the playlist.

Parameters:

author (int) – The new author of the playlist.

async update_name(name)[source]#

Update the name of the playlist.

Parameters:

name (str) – The new name of the playlist.

async update_scope(scope)[source]#

Update the scope of the playlist.

Parameters:

scope (int) – The new scope of the playlist.

async update_tracks(tracks)[source]#

Update the tracks of the playlist.

Parameters:

tracks (list[str]) – The new tracks of the playlist.

async update_url(url)[source]#

Update the url of the playlist.

Parameters:

url (str) – The new url of the playlist.

pylav.storage.models.query module#

class pylav.storage.models.query.Query(*args: 'Any', **kwargs: 'Any')[source]#

Bases: CachedModel

async bulk_update(tracks, name, info=None, plugin_info=None)[source]#

Bulk update the query.

Parameters:
  • tracks (list[str | Track]) – The tracks of the playlist.

  • name (str) – The name of the playlist

async delete()[source]#

Delete the query from the database

async exists()[source]#

Check if the config exists.

Returns:

Whether the config exists.

Return type:

bool

async fetch_bulk(info=False, name=False, pluginInfo=False, tracks=False)[source]#

Get all tracks.

Returns:

All tracks

Return type:

list[str]

async fetch_first()[source]#

Get the first track.

Returns:

The first track

Return type:

str

async fetch_index(index)[source]#

Get the track at the index.

Parameters:

index (int) – The index of the track

Returns:

The track at the index

Return type:

str

async fetch_info()[source]#

Get the info of the playlist.

Returns:

The plugin info of the playlist.

Return type:

JSON_DICT_TYPE

async fetch_last_updated()[source]#

Get the last updated time of the playlist.

Returns:

The last updated time of the playlist.

Return type:

datetime

async fetch_name()[source]#

Get the name of the playlist.

Returns:

The name of the playlist.

Return type:

str

async fetch_plugin_info()[source]#

Get the plugin info of the playlist.

Returns:

The plugin info of the playlist.

Return type:

JSON_DICT_TYPE

async fetch_random()[source]#

Get a random track.

Returns:

A random track

Return type:

str

async fetch_tracks()[source]#

Get the tracks of the playlist.

Returns:

The tracks of the playlist.

Return type:

list[str]

get_cache_key()[source]#
id#
async size()[source]#

Count the tracks of the playlist.

Returns:

The number of tracks in the playlist.

Return type:

int

async update_info(info)[source]#

Update the info of the playlist.

Parameters:

info (JSON_DICT_TYPE) – The plugin info of the playlist.

async update_last_updated()[source]#

Update the last updated time of the playlist

async update_name(name)[source]#

Update the name of the playlist.

Parameters:

name (str) – The name of the playlist.

async update_plugin_info(plugin_info)[source]#

Update the plugin info of the playlist.

Parameters:

plugin_info (JSON_DICT_TYPE) – The plugin info of the playlist.

async update_tracks(tracks)[source]#

Update the tracks of the playlist.

Parameters:

tracks (list[str | Track]) – The tracks of the playlist.

pylav.storage.models.version module#

class pylav.storage.models.version.BotVersion(*args, **kwargs)[source]#

Bases: CachedModel

A class to represent the version of the bot in the database

async fetch_version()[source]#

Fetch the version of the bot from the database

get_cache_key()[source]#

Get the cache key for the bot version.

id#
async update_version(version)[source]#

Update the version of the bot in the database

Module contents#