Skip to content

Commit

Permalink
Add raw_data field to playable.
Browse files Browse the repository at this point in the history
  • Loading branch information
EvieePy committed Dec 16, 2023
1 parent 5f926ea commit 68f56e5
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions wavelink/tracks.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ def __init__(self, data: TrackPayload, *, playlist: PlaylistInfo | None = None)

self._extras: ExtrasNamespace = ExtrasNamespace(data.get("userData", {}))

self._raw_data = data

def __hash__(self) -> int:
return hash(self.encoded)

Expand Down Expand Up @@ -294,6 +296,29 @@ def extras(self, __value: ExtrasNamespace | dict[str, Any]) -> None:
else:
self._extras = ExtrasNamespace(__value)

@property
def raw_data(self) -> TrackPayload:
"""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: wavelink.Playable = wavelink.Playable(old_data)
.. versionadded:: 3.2.0
"""
return self._raw_data

@classmethod
async def search(cls, query: str, /, *, source: TrackSource | str | None = TrackSource.YouTubeMusic) -> Search:
"""Search for a list of :class:`~wavelink.Playable` or a :class:`~wavelink.Playlist`, with the given query.
Expand Down

0 comments on commit 68f56e5

Please sign in to comment.