Skip to content

Commit

Permalink
feat: add track decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
ooliver1 committed Oct 21, 2022
1 parent 036fa65 commit 278d1d0
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion mafic/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

from aiohttp import ClientSession, WSMsgType

from mafic.typings.http import TrackWithInfo

from .__libraries import ExponentialBackoff, dumps, loads
from .errors import TrackLoadException
from .playlist import Playlist
Expand All @@ -30,6 +32,7 @@
IncomingMessage,
OutgoingMessage,
PlayPayload,
TrackInfo,
)

_log = getLogger(__name__)
Expand Down Expand Up @@ -461,7 +464,21 @@ async def fetch_tracks(
else:
_log.warning("Unknown load type recieved: %s", data["loadType"])

# TODO: decode track
async def decode_track(self, track: str) -> Track:
# TODO: handle errors from lavalink
info: TrackInfo = await self.__request(
"GET", "/decodetrack", params={"track": track}
)

return Track.from_data(track=track, info=info)

async def decode_tracks(self, tracks: list[str]) -> list[Track]:
track_data: list[TrackWithInfo] = await self.__request(
"POST", "/decodetracks", json=tracks
)

return [Track.from_data(**track) for track in track_data]

# TODO: plugins
# TODO: route planner status
# TODO: unmark failed address
Expand Down

0 comments on commit 278d1d0

Please sign in to comment.