Skip to content

Commit

Permalink
feat: add plugin endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
ooliver1 committed Oct 21, 2022
1 parent 278d1d0 commit abbb893
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
8 changes: 7 additions & 1 deletion mafic/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from .__libraries import ExponentialBackoff, dumps, loads
from .errors import TrackLoadException
from .playlist import Playlist
from .plugin import Plugin
from .track import Track

if TYPE_CHECKING:
Expand All @@ -32,6 +33,7 @@
IncomingMessage,
OutgoingMessage,
PlayPayload,
PluginData,
TrackInfo,
)

Expand Down Expand Up @@ -479,7 +481,11 @@ async def decode_tracks(self, tracks: list[str]) -> list[Track]:

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

# TODO: plugins
async def fetch_plugins(self) -> list[Plugin]:
plugins: list[PluginData] = await self.__request("GET", "/plugins")

return [Plugin(**plugins) for plugins in plugins]

# TODO: route planner status
# TODO: unmark failed address
# TODO: unmark all failed addresses
11 changes: 11 additions & 0 deletions mafic/plugin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# SPDX-License-Identifier: MIT

from __future__ import annotations

from dataclasses import dataclass


@dataclass(repr=True)
class Plugin:
name: str
version: str
6 changes: 6 additions & 0 deletions mafic/typings/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
__all__ = (
"GetTracks",
"PlaylistInfo",
"PluginData",
"Tracks",
"TrackInfo",
"TrackWithInfo",
Expand Down Expand Up @@ -55,3 +56,8 @@ class TracksFailed(TypedDict):


GetTracks = Union[Tracks, TracksFailed]


class PluginData(TypedDict):
name: str
version: str

0 comments on commit abbb893

Please sign in to comment.