Models¶
All the models (also called “Entities”) of Andesite, but as Python classes. This makes interacting with them a lot more comfortable.
The models reside in modules of the andesite.models
module, but they are all exported
to the andesite
module, so you can import them from there.
Player¶
Player models.
-
MixerMap
¶ (Type alias) Mapping from player id to
MixerPlayer
- Type
Dict[str, MixerPlayer]
-
class
BasePlayer
(time, position, paused, volume, filters, frame)[source]¶ Bases:
abc.ABC
Abstract class for Andesite players.
See also
-
time
¶ current utc datetime on the node
- Type
datetime
-
frame
¶ - Type
-
-
class
MixerPlayer
(time, position, paused, volume, filters, frame)[source]¶ Bases:
andesite.models.player.BasePlayer
Player used by
Player
as a mixer player.See also
Track¶
Track models.
-
class
PlaylistInfo
(name, selected_track)[source]¶ Information for of the playlist a track belongs to.
-
name
¶ name of the playlist
-
-
class
TrackMetadata
(class_name, title, author, length, identifier, uri, is_stream, is_seekable, position)[source]¶ Additional information for a track.
author of the track
- Type
-
length
¶ duration of the track, in seconds. Set to
None
if it’s a stream. Andesite would normally return 2^63 - 1 (Long.MAX_VALUE), but that value doesn’t have any significance in Python so it’s represented with something more meaningful.- Type
Optional[float]
Whether or not the author is unknown.
Uses constant
UNKNOWN_ARTIST
to check against.Keep in mind that there is no way to detect whether the author’s name just happens to coincide with the
UNKNOWN_ARTIST
text. Use with caution.- Return type
-
class
TrackInfo
(track, info)[source]¶ Track info represents a track and its metadata.
-
info
¶ metadata of the track
- Type
-
-
class
LoadType
[source]¶ Load type of a
LoadedTrack
-
TRACK_LOADED
= 'TRACK_LOADED'¶
-
SEARCH_RESULT
= 'SEARCH_RESULT'¶
-
PLAYLIST_LOADED
= 'PLAYLIST_LOADED'¶
-
NO_MATCHES
= 'NO_MATCHES'¶
-
LOAD_FAILED
= 'LOAD_FAILED'¶
-
property
success
¶ Whether the load type is a successful one.
Only
LOAD_FAILED
counts as unsuccessful.- Return type
-
-
class
LoadedTrack
(load_type, tracks, playlist_info, cause=None, severity=None)[source]¶ Result provided by a load track request.
-
playlist_info
¶ metadata of the loaded playlist
- Type
Optional[PlaylistInfo]
This class provides the magic methods
__bool__
and__len__
which operate in respect totracks
.-
cause
= None
-
severity
= None
-
get_selected_track
()[source]¶ Get the selected track.
“Selected” means that either the result is a playlist with an entry selected (
PlaylistInfo.selected_track
), or the result is aLoadType.TRACK_LOADED
result (in which case the first and only track is returned).All other cases will return in
None
being returned.
-
Filters¶
Andesite audio filters.
-
FILTER_MAP
¶ Mapping from filter name to filter class. See:
get_filter_model
.
-
FilterMapLike
¶ (Type alias) Type of objects which can be used as filter maps. This includes the
FilterMap
.
-
class
Filter
(enabled=True)[source]¶ Audio filter for Andesite.
-
enabled
¶ Whether or not the filter is enabled. This value is mostly useful when receiving the filters from Andesite. However you can also set it to
False
when sending filters. This will cause the settings to be ignored and instead the default values are sent to Andesite which will cause the filter to be disabled.- Type
When creating a new
Filter
instance its values are set to the default value.-
enabled
= True
-
-
class
EqualizerBand
(band, gain=0.0)[source]¶ -
-
gain
= 0.0
-
set_band
(value)[source]¶ Setter for
band
which performs a value check.- Parameters
value (
int
) – Value to set for the band. ( [0, 14] )- Raises
ValueError – if the provided value is invalid.
- Return type
None
-
set_gain
(value)[source]¶ Setter for
gain
which performs a value check.- Parameters
value (
float
) – Value to set for the gain. ( [-0.25, 1] )- Raises
ValueError – if the provided value is invalid.
- Return type
None
-
-
class
Equalizer
(enabled=True, bands=<factory>)[source]¶ -
bands
¶ array of bands to configure
- Type
List[EqualizerBand]
-
get_band
(band, create=True)[source]¶ Get the specified band from the bands list.
If the band doesn’t exist it is created. If you don’t want to automatically create a band, pass
create=False
.- Parameters
- Return type
-
set_band_gain
(band, gain)[source]¶ Set the gain of a band to the specified value.
If the band does not exist it is created.
- Parameters
- Raises
ValueError – if the provided gain is invalid.
- Return type
None
-
-
class
Karaoke
(enabled=True, level=1.0, mono_level=1.0, filter_band=220.0, filter_width=100.0)[source]¶ -
-
level
= 1.0
-
mono_level
= 1.0
-
filter_band
= 220.0
-
filter_width
= 100.0
-
-
class
Timescale
(enabled=True, speed=1.0, pitch=1.0, rate=1.0)[source]¶ -
-
speed
= 1.0
-
pitch
= 1.0
-
rate
= 1.0
-
set_speed
(value)[source]¶ Setter for
speed
which performs a value check.- Parameters
value (
float
) – Value to set for the speed. ( (0, INF] )- Raises
ValueError – if the provided value is invalid.
- Return type
None
-
set_pitch
(value)[source]¶ Setter for
pitch
which performs a value check.- Parameters
value (
float
) – Value to set for the pitch. ( (0, INF] )- Raises
ValueError – if the provided value is invalid.
- Return type
None
-
set_rate
(value)[source]¶ Setter for
rate
which performs a value check.- Parameters
value (
float
) – Value to set for the rate. ( (0, INF] )- Raises
ValueError – if the provided value is invalid.
- Return type
None
-
-
class
Tremolo
(enabled=True, frequency=2.0, depth=0.5)[source]¶ -
-
frequency
= 2.0
-
depth
= 0.5
-
set_frequency
(value)[source]¶ Setter for
frequency
which performs a value check.- Parameters
value (
float
) – Value to set for the frequency. ( (0, INF] )- Raises
ValueError – if the provided value is invalid.
- Return type
None
-
set_depth
(value)[source]¶ Setter for
depth
which performs a value check.- Parameters
value (
float
) – Value to set for the depth. ( (0, 1] )- Raises
ValueError – if the provided value is invalid.
- Return type
None
-
-
class
Vibrato
(enabled=True, frequency=2.0, depth=0.5)[source]¶ -
-
frequency
= 2.0
-
depth
= 0.5
-
set_frequency
(value)[source]¶ Setter for
frequency
which performs a value check.- Parameters
value (
float
) – Value to set for the frequency. ( (0, 14] )- Raises
ValueError – if the provided value is invalid.
- Return type
None
-
set_depth
(value)[source]¶ Setter for
depth
which performs a value check.- Parameters
value (
float
) – Value to set for the depth. ( (0, 1] )- Raises
ValueError – if the provided value is invalid.
- Return type
None
-
-
get_filter_model
(name)[source]¶ Get the corresponding filter model for the given name.
If no model for the name exists,
None
is returned.
-
class
FilterMap
(filters)[source]¶ Custom mapping type for filters.
Theoretically this is just a wrapper around the
filters
dictionary which contains the actual filter data. The class exposes the known filters as properties, but it also supports unknown filters should the library become outdated.You can also use this as a wrapper for an existing filter dict.
-
property
volume
¶ Volume filter settings
- Return type
-
property
Send Operations¶
Sendable operations to Andesite.
These operations can be sent using AbstractWebSocket.send_operation
.
See also
andesite.models.receive_operations
for operations sent by Andesite.
-
MixerPlayerUpdateMap
¶ (Type alias) str ->
Play
/Update
map used by theMixerUpdate
.
-
class
SendOperation
[source]¶ SendOperation is a model that can be passed as a payload to the
WebSocket
client.See also
WebSocket.send_operation
-
class
Play
(track, start=None, end=None, pause=None, volume=None, no_replace=False)[source]¶ Operation playing a track.
-
no_replace
¶ if
True
and a track is already playing/paused, this command is ignored. (Defaults toFalse
)- Type
-
start
= None
-
end
= None
-
pause
= None
-
volume
= None
-
no_replace
= False
-
-
class
FilterUpdate
(filters)[source]¶ Operation adjusting the filter settings.
See also
This class inherits from
FilterMap
.
-
class
Update
(pause=None, position=None, volume=None, filters=None)[source]¶ Operation providing an update for the current track.
-
filters
¶ configuration for the filters
- Type
Optional[FilterUpdate]
-
pause
= None
-
position
= None
-
volume
= None
-
filters
= None
-
Receive Operations¶
Operations sent by Andesite.
-
EVENT_MAP
¶ Mapping from the event name to the corresponding
AndesiteEvent
type. See:get_event_model
- Type
Mapping[str, Type[AndesiteEvent]]
-
OP_MAP
¶ Mapping from the op code to
- Type
Mapping[str, Type[ReceiveOperation]]
-
the corresponding `ReceiveOperation` type. See
See also
andesite.models.send_operations
for operations sent to Andesite.
-
class
ReceiveOperation
[source]¶ Message sent by Andesite.
-
client
¶ Client that received the message. This is set by the client that received the message.
- Type
Optional[andesite.AbstractWebSocketClient]
-
client
= None
-
-
class
PongResponse
(user_id, guild_id)[source]¶ Simple pong response sent as a response to ping requests.
-
class
MetadataUpdate
(data)[source]¶ Payload sent on connection start containing handshake response header.
-
class
StatsUpdate
(user_id, stats)[source]¶ Message containing statistics.
-
stats
¶ Statistics
- Type
andesite.Stats
-
-
class
PlayerUpdate
(user_id, guild_id, state)[source]¶ Player update sent by Andesite for active players.
-
state
¶ State of the player.
None
if no player exists yet.- Type
Optional[andesite.Player]
-
-
class
AndesiteEvent
(type, user_id, guild_id)[source]¶ Event sent by Andesite.
-
type
¶ Event type name. This is equal to the name of the class (With the exception of
UnknownAndesiteEvent
)- Type
-
-
class
TrackStartEvent
(type, user_id, guild_id, track)[source]¶ Event emitted when a new track starts playing.
-
class
TrackEndReason
[source]¶ Reason why a track stopped playing.
See also
-
FINISHED
¶ Usually caused by the track reaching the end, however it will also be used when it ends due to an exception.
-
LOAD_FAILED
¶ Track failed to start, throwing an exception before providing any audio.
-
STOPPED
¶ Track was stopped due to the player being stopped.
-
REPLACED
¶ Track stopped playing because a new track started playing.
-
CLEANUP
¶ Track was stopped because the cleanup threshold for the audio player was reached.
-
FINISHED
= 'FINISHED'
-
LOAD_FAILED
= 'LOAD_FAILED'
-
STOPPED
= 'STOPPED'
-
REPLACED
= 'REPLACED'
-
CLEANUP
= 'CLEANUP'
-
-
class
TrackEndEvent
(type, user_id, guild_id, track, reason, may_start_next)[source]¶ Event emitted when a track ended.
-
reason
¶ Reason why a track stopped playing.
- Type
-
may_start_next
¶ Indicates whether a new track should be started on receiving this event. If this is
False
, either this event is already triggered because another track started (TrackEndReason.REPLACED
) or because the player is stopped (TrackEndReason.STOPPED
,TrackEndReason.CLEANUP
).- Type
-
-
class
TrackExceptionEvent
(type, user_id, guild_id, track, error, exception)[source]¶ Event emitted when there’s an error.
-
class
TrackStuckEvent
(type, user_id, guild_id, track, threshold)[source]¶ Event emitted when a track is stuck.
-
class
WebSocketClosedEvent
(type, user_id, guild_id, reason, code, by_remote)[source]¶ Event emitted when the Andesite node disconnects from a voice channel.
-
class
UnknownAndesiteEvent
(type, user_id, guild_id, body)[source]¶ Special kind of event for unknown events.
This shouldn’t occur at all unless the library is out-dated.
-
get_event_model
(event_type)[source]¶ Get the model corresponding to the given event name.
- Parameters
event_type (
str
) – Event type name.- Return type
- Returns
Model type for the given event type.
UnknownAndesiteEvent
if no matching event was found.
-
get_update_model
(op, event_type=None)[source]¶ Get the model corresponding to the given op code.
- Parameters
op (
str
) – Op code sent by Andesiteevent_type (
Optional
[str
]) – Event type if and only if op is “event”. This is used to return the correct event type. Seeget_event_model
. If not set and op is “event” the function returnsNone
.
- Return type
Debug¶
Debug models for Andesite.
These models are used in either Stats
which represents the Andesite
stats returned by WebSocketInterface.get_stats
or Error
which is
used to represent an Andesite error.
-
class
StackFrame
(class_loader, module_name, module_version, class_name, method_name, file_name, line_number, pretty)[source]¶ Andesite stack frame.
Can be found in
Error.stack
.
-
class
Error
(class_name, message, stack, suppressed, cause)[source]¶ Andesite error.
You can convert the Andesite error data into a Python exception using the
as_python_exception
method and theraise_python_exception
to raise it.-
stack
¶ stacktrace of the error
- Type
List[StackFrame]
-
as_python_exception
()[source]¶ Create an
AndesiteException
which can be raised.If
cause
is notNone
it is added to the exception.- Return type
-
raise_error
()[source]¶ Raise the Andesite error as an
AndesiteException
.- Raises
AndesiteException – Generated using the
as_python_exception
method.- Return type
-
-
exception
AndesiteException
(class_name, message, stack, suppressed)[source]¶ Andesite’s
Error
represented as python exceptions.-
stack
¶ cause of the error
- Type
List[StackFrame]
-
-
class
PlayersStats
(total, playing)[source]¶ Players statistics sent by Andesite.
See also
This statistic can be found in
Stats
which is retrieved from Andesite by the clients. BothHTTP
andWebSocket
are able to get them.
-
class
RuntimeVMStats
(name, vendor, version)[source]¶ VM statistics.
See also
This statistic can be found in
Stats
which is retrieved from Andesite by the clients. BothHTTP
andWebSocket
are able to get them.
-
class
RuntimeSpecStats
(name, vendor, version)[source]¶ Spec statistics.
See also
This statistic can be found in
Stats
which is retrieved from Andesite by the clients. BothHTTP
andWebSocket
are able to get them.
-
class
RuntimeVersionStats
(feature, interim, update, patch, pre, build, optional)[source]¶ Version information stats.
See also
This statistic can be found in
Stats
which is retrieved from Andesite by the clients. BothHTTP
andWebSocket
are able to get them.
-
class
RuntimeStats
(uptime, pid, management_spec_version, name, vm, spec, version)[source]¶ Runtime statistics.
-
vm
¶ - Type
-
spec
¶ - Type
-
version
¶ - Type
See also
This statistic can be found in
Stats
which is retrieved from Andesite by the clients. BothHTTP
andWebSocket
are able to get them.-
-
class
OSStats
(processors, name, arch, version)[source]¶ OS statistics.
See also
This statistic can be found in
Stats
which is retrieved from Andesite by the clients. BothHTTP
andWebSocket
are able to get them.
-
class
CPUStats
(andesite, system)[source]¶ CPU statistics.
See also
This statistic can be found in
Stats
which is retrieved from Andesite by the clients. BothHTTP
andWebSocket
are able to get them.
-
class
ThreadStats
(running, daemon, peak, total_started)[source]¶ Thread statistics.
See also
This statistic can be found in
Stats
which is retrieved from Andesite by the clients. BothHTTP
andWebSocket
are able to get them.
-
class
CompilationStats
(name, total_time)[source]¶ Compilation statistics.
See also
This statistic can be found in
Stats
which is retrieved from Andesite by the clients. BothHTTP
andWebSocket
are able to get them.
-
class
MemoryCommonUsageStats
(init, used, committed, max)[source]¶ Memory usage statistics.
See also
This statistic can be found in
Stats
which is retrieved from Andesite by the clients. BothHTTP
andWebSocket
are able to get them.
-
class
MemoryStats
(pending_finalization, heap, non_heap)[source]¶ Memory statistics.
-
heap
¶
-
non_heap
¶
See also
This statistic can be found in
Stats
which is retrieved from Andesite by the clients. BothHTTP
andWebSocket
are able to get them.-
-
class
GCStats
(name, collection_count, collection_time, pools)[source]¶ Garbage collection statistics.
See also
This statistic can be found in
Stats
which is retrieved from Andesite by the clients. BothHTTP
andWebSocket
are able to get them.
-
class
MemoryPoolStats
(name, type, collection_usage, collection_usage_threshold, collection_usage_threshold_count, peak_usage, usage, usage_threshold, usage_threshold_count, managers)[source]¶ Memory pool statistics.
-
collection_usage
¶ - Type
Optional[MemoryHeapStats]
-
peak_usage
¶
-
usage
¶
See also
This statistic can be found in
Stats
which is retrieved from Andesite by the clients. BothHTTP
andWebSocket
are able to get them.-
-
class
MemoryManagerStats
(name, pools)[source]¶ Memory manager statistics.
See also
This statistic can be found in
Stats
which is retrieved from Andesite by the clients. BothHTTP
andWebSocket
are able to get them.
-
class
FrameStats
(user, guild, success, loss)[source]¶ Frame statistics for a guild player.
See also
This statistic can be found in
Stats
which is retrieved from Andesite by the clients. BothHTTP
andWebSocket
are able to get them.
-
class
Stats
(players, runtime, os, cpu, class_loading, thread, compilation, memory, gc, memory_pools, memory_managers, frame_stats)[source]¶ Statistics sent by Andesite
-
players
¶ Player statistics
- Type
-
runtime
¶ Runtime statistics
- Type
-
class_loading
¶ Class loading statistics
- Type
-
thread
¶ Thread statistics
- Type
-
compilation
¶ Compilation statistics
- Type
-
memory
¶ Memory statistics
- Type
-
memory_pools
¶ Memory pool statistics
- Type
List[MemoryPoolStats]
-
memory_managers
¶ Memory manager statistics
- Type
List[MemoryManagerStats]
-
frame_stats
¶ Frame statistics
- Type
List[FrameStats]
-