From 9d965567e663c6d3dba85d72bc45a1c0ad7321e8 Mon Sep 17 00:00:00 2001 From: Danielle McLean Date: Fri, 17 May 2024 10:18:18 +1000 Subject: [PATCH] Add methods for calling MPD's albumart command --- src/mpd_now_playable/mpd/listener.py | 7 +++++++ stubs/mpd/asyncio.pyi | 1 + 2 files changed, 8 insertions(+) diff --git a/src/mpd_now_playable/mpd/listener.py b/src/mpd_now_playable/mpd/listener.py index 9559937..960dc8c 100644 --- a/src/mpd_now_playable/mpd/listener.py +++ b/src/mpd_now_playable/mpd/listener.py @@ -95,6 +95,13 @@ class MpdStateListener(Player): print(song) listener.update(song) + async def albumart(self, file: str) -> bytes | None: + try: + albumart = await self.client.albumart(file) + return albumart.get("binary") + except CommandError: + return None + async def readpicture(self, file: str) -> bytes | None: try: readpic = await self.client.readpicture(file) diff --git a/stubs/mpd/asyncio.pyi b/stubs/mpd/asyncio.pyi index 221fcf4..6968141 100644 --- a/stubs/mpd/asyncio.pyi +++ b/stubs/mpd/asyncio.pyi @@ -13,6 +13,7 @@ class MPDClient(MPDClientBase): def idle(self, subsystems: Sequence[str] = ...) -> AsyncIterator[Sequence[str]]: ... async def status(self) -> types.StatusResponse: ... async def currentsong(self) -> types.CurrentSongResponse: ... + async def albumart(self, uri: str) -> types.ReadPictureResponse: ... async def readpicture(self, uri: str) -> types.ReadPictureResponse: ... async def play(self) -> None: ... async def pause(self, pause: Literal[1, 0, None] = None) -> None: