Playable¶
A Playable represents a single audio track. Use Playable.search() to search for tracks.
Playable.search() returns Search, a type alias for list[Playable] | Playlist.
results: revvlink.Search = await revvlink.Playable.search("lofi chill")
if isinstance(results, revvlink.Playlist):
await player.queue.put_wait(results)
elif results:
await player.play(results[0])
Guide
See the Tracks & Search Guide for source selection, URL searching, and playlist handling.
Playable ¶
The RevvLink Playable object which represents all tracks in RevvLink 3.
You should not construct this class manually.
str(track)The title of this playable.repr(track)The official string representation of this playable.track == otherWhether this track is equal to another. Checks both the track encoding and identifier.
encoded
property
¶
The encoded track string from Lavalink.
Returns:
| Type | Description |
|---|---|
str
|
The base64 encoded track string. |
identifier
property
¶
The identifier of this track from its source.
E.g. YouTube ID or Spotify ID.
Returns:
| Type | Description |
|---|---|
str
|
The track identifier. |
is_seekable
property
¶
Whether this track supports seeking.
Returns:
| Type | Description |
|---|---|
bool
|
True if seekable, False otherwise. |
author
property
¶
The author or artist of this track.
Returns:
| Type | Description |
|---|---|
str
|
The track author. |
length
property
¶
The duration of this track in milliseconds.
Returns:
| Type | Description |
|---|---|
int
|
The track length in ms. |
is_stream
property
¶
Whether this track is an ongoing stream.
Returns:
| Type | Description |
|---|---|
bool
|
True if a stream, False otherwise. |
position
property
¶
The starting position of this track in milliseconds.
Returns:
| Type | Description |
|---|---|
int
|
The start position in ms. |
title
property
¶
The title or name of this track.
Returns:
| Type | Description |
|---|---|
str
|
The track title. |
uri
property
¶
The URL to this track.
Returns:
| Type | Description |
|---|---|
str | None
|
The track URI, or |
artwork
property
¶
The URL to the artwork for this track.
Returns:
| Type | Description |
|---|---|
str | None
|
The artwork URL, or |
isrc
property
¶
The International Standard Recording Code (ISRC) for this track.
Returns:
| Type | Description |
|---|---|
str | None
|
The ISRC, or |
source
property
¶
The source name for this track.
E.g. "spotify" or "youtube".
Returns:
| Type | Description |
|---|---|
str
|
The source name. |
album
property
¶
The album data associated with this track.
Returns:
| Type | Description |
|---|---|
class:`Album`
|
The album information. |
artist
property
¶
The artist data associated with this track.
Returns:
| Type | Description |
|---|---|
class:`Artist`
|
The artist information. |
preview_url
property
¶
The URL to a short preview of this track.
Returns:
| Type | Description |
|---|---|
str | None
|
The preview URL, or |
is_preview
property
¶
Whether this track is a short preview.
Returns:
| Type | Description |
|---|---|
bool | None
|
True if a preview, False otherwise, or |
playlist
property
¶
The playlist information if this track part of one.
Returns:
| Type | Description |
|---|---|
class:`PlaylistInfo` | None
|
The playlist info, or |
recommended
property
¶
Whether this track was added via the AutoPlay feature.
Returns:
| Type | Description |
|---|---|
bool
|
True if recommended, False otherwise. |
extras
property
writable
¶
Property returning a :class:~revvlink.ExtrasNamespace of extras
for this :class:Playable.
You can set this property with a :class:dict of valid :class:str
keys to any valid JSON value, or a :class:~revvlink.ExtrasNamespace.
If a dict is passed, it will be converted into an
:class:~revvlink.ExtrasNamespace, which can be converted back to a
dict with dict(...). Additionally, you can also use list or tuple on
:class:~revvlink.ExtrasNamespace.
The extras dict will be sent to Lavalink as the userData field.
This is only available when using Lavalink 4+ (Non BETA) versions.
Examples:
.. code:: python
track: revvlink.Playable = revvlink.Playable.search("QUERY")
track.extras = {"requester_id": 1234567890}
# later...
print(track.extras.requester_id)
# or
print(dict(track.extras)["requester_id"])
raw_data
property
¶
The raw data for this Playable received via Lavalink.
You can use this data to reconstruct this Playable object.
Examples:
.. code:: python3
# For example purposes...
old_data = track.raw_data
# Later...
track: revvlink.Playable = revvlink.Playable(old_data)
search
async
classmethod
¶
search(
query: str,
/,
*,
source: TrackSource
| str
| None = TrackSource.YouTubeMusic,
node: Node | None = None,
) -> Search
Search for a list of :class:~revvlink.Playable or a
:class:~revvlink.Playlist, with the given query.
This method differs from revvlink.Pool.fetch_tracks in that it will apply a relevant search prefix for you when a URL is not provided. This prefix can be controlled via the source keyword argument.
This method of searching is preferred over, revvlink.Pool.fetch_tracks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
The query to search tracks for. If this is not a URL based search,
this method will provide an appropriate search prefix based on what is
provided to the If this query is a URL, a search prefix will not be used. |
required |
source
|
TrackSource | str | None
|
This parameter determines which search prefix to use when searching for tracks.
If For basic searches, E.g. YouTube, YouTubeMusic and SoundCloud,
see: :class: Defaults to :attr: |
YouTubeMusic
|
node
|
Node | None
|
An optional :class: |
None
|
Returns:
| Type | Description |
|---|---|
class:`revvlink.Search`
|
A list of [:class: |
Raises:
| Type | Description |
|---|---|
LavalinkLoadException
|
Exception raised when Lavalink fails to load results based on your query. |
Examples:
# Search for tracks, with the default "ytsearch:" prefix.
tracks: revvlink.Search = await revvlink.Playable.search("Ocean Drive")
if not tracks:
# No tracks were found...
...
# Search for tracks, with a URL.
tracks: revvlink.Search = await revvlink.Playable.search("https://www.youtube.com/watch?v=KDxJlW6cxRk")
...
# Search for tracks, using Spotify and the LavaSrc Plugin.
tracks: revvlink.Search = await revvlink.Playable.search(
"4b93D55xv3YCH5mT4p6HPn", source="spsearch"
)
...
# Search for tracks, using Spotify and the LavaSrc Plugin, with a URL.
tracks: revvlink.Search = await revvlink.Playable.search("https://open.spotify.com/track/4b93D55xv3YCH5mT4p6HPn")
...
# Search for a playlist, using Spotify and the LavaSrc Plugin.
# or alternatively any other playlist URL from another source like YouTube.
tracks: revvlink.Search = await revvlink.Playable.search("https://open.spotify.com/playlist/37i9dQZF1DWXRqgorJj26U")
...
# Set extras on a playlist result.
playlist: revvlink.Playlist = await revvlink.Playable.search("https://open.spotify.com/playlist/37i9dQZF1DWXRqgorJj26U")
playlist.extras = {"requester_id": 1234567890}
# later...
print(track.extras.requester_id)
# or
print(dict(track.extras)["requester_id"])
Playlist ¶
The revvlink Playlist container class.
This class is created and returned via both :meth:Playable.search and
:meth:revvlink.Pool.fetch_tracks.
It contains various information about the playlist and a list of
:class:Playable that can be used directly in
:meth:revvlink.Player.play. See below for various supported operations.
You should not instantiate this class manually, use Playable.search or revvlink.Pool.fetch_tracks instead.
You can not use .search directly on this class, see: Playable.search.
This class can be directly added to revvlink.Queue identical to Playable. When added, all tracks contained in this playlist, will be individually added to the revvlink.Queue.
str(x)Return the name associated with this playlist.repr(x)Return the official string representation of this playlist.x == yCompare the equality of playlist.len(x)Return an integer representing the amount of tracks contained in this playlist.x[0]Return a track contained in this playlist with the given index.x[0:2]Return a slice of tracks contained in this playlist.for x in yIterate over the tracks contained in this playlist.reversed(x)Reverse the tracks contained in this playlist.x in yCheck if a :class:`Playable` is contained in this playlist.Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
The name of this playlist. |
selected |
int
|
The index of the selected track from Lavalink. |
tracks |
list[:class:`Playable`]
|
A list of :class: |
type |
str | None
|
An optional |
url |
str | None
|
An optional |
artwork |
str | None
|
An optional |
author |
str | None
|
An optional |
extras
property
writable
¶
The extras associated with this :class:Playlist.
This property can be set with a :class:dict of valid :class:str
keys to any valid JSON value, or a :class:~revvlink.ExtrasNamespace.
If a dict is passed, it will be converted into an
:class:~revvlink.ExtrasNamespace, which can be converted back to a
dict with dict(...). Additionally, you can also use list or tuple
on :class:~revvlink.ExtrasNamespace.
The extras dict will be sent to Lavalink as the userData field for
each track in the playlist.
This is only available when using Lavalink 4+ (Non BETA) versions.
Examples:
playlist: revvlink.Search = revvlink.Playable.search("QUERY")
playlist.extras = {"requester_id": 1234567890}
# later...
print(track.extras.requester_id)
# or
print(dict(track.extras)["requester_id"])
Returns:
| Type | Description |
|---|---|
class:`~revvlink.ExtrasNamespace`
|
The playlist extras. |
track_extras ¶
Method which sets attributes to all :class:Playable in this
playlist, with the provided keyword arguments.
This is useful when you need to attach state to your :class:Playable,
E.g. create a requester attribute.
If you try to override any existing property of Playable this method will fail.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**attrs
|
object
|
The keyword arguments to set as attribute name=value on each :class: |
{}
|
Examples:
.. code:: python3
playlist.track_extras(requester=ctx.author)
track: revvlink.Playable = playlist[0]
print(track.requester)
PlaylistInfo ¶
The revvlink PlaylistInfo container class.
It contains various information about the playlist but does not contain the tracks associated with this playlist.
This class provides information about the original
:class:revvlink.Playlist on tracks.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
The name of this playlist. |
selected |
int
|
The index of the selected track from Lavalink. |
tracks |
int
|
The amount of tracks this playlist originally contained. |
type |
str | None
|
An optional |
url |
str | None
|
An optional |
artwork |
str | None
|
An optional |
author |
str | None
|
An optional |
Album ¶
Container class representing Album data received via Lavalink.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str | None
|
The album name. Could be |
url |
str | None
|
The album url. Could be |
Artist ¶
Container class representing Artist data received via Lavalink.
Attributes:
| Name | Type | Description |
|---|---|---|
url |
str | None
|
The artist url. Could be |
artwork |
str | None
|
The artist artwork url. Could be |