Skip to content

Commit

Permalink
Merge pull request #264 from PythonistaGuild/feature/playable-rawdata
Browse files Browse the repository at this point in the history
Feature/playable rawdata
  • Loading branch information
EvieePy authored Dec 16, 2023
2 parents 5f926ea + 7c7d82e commit dcd61d7
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "wavelink"
version = "3.1.0"
version = "3.2.0"
authors = [
{ name="PythonistaGuild, EvieePy", email="[email protected]" },
]
Expand Down
2 changes: 1 addition & 1 deletion wavelink/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
__author__ = "PythonistaGuild, EvieePy"
__license__ = "MIT"
__copyright__ = "Copyright 2019-Present (c) PythonistaGuild, EvieePy"
__version__ = "3.1.0"
__version__ = "3.2.0"


from .enums import *
Expand Down
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 dcd61d7

Please sign in to comment.