Add methods for calling MPD's albumart command

This commit is contained in:
Danielle McLean 2024-05-17 10:18:18 +10:00
parent 8ad255856e
commit 569372d4e2
Signed by: 00dani
GPG key ID: 6854781A0488421C
2 changed files with 8 additions and 0 deletions

View file

@ -95,6 +95,13 @@ class MpdStateListener(Player):
print(song) print(song)
listener.update(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: async def readpicture(self, file: str) -> bytes | None:
try: try:
readpic = await self.client.readpicture(file) readpic = await self.client.readpicture(file)

View file

@ -13,6 +13,7 @@ class MPDClient(MPDClientBase):
def idle(self, subsystems: Sequence[str] = ...) -> AsyncIterator[Sequence[str]]: ... def idle(self, subsystems: Sequence[str] = ...) -> AsyncIterator[Sequence[str]]: ...
async def status(self) -> types.StatusResponse: ... async def status(self) -> types.StatusResponse: ...
async def currentsong(self) -> types.CurrentSongResponse: ... async def currentsong(self) -> types.CurrentSongResponse: ...
async def albumart(self, uri: str) -> types.ReadPictureResponse: ...
async def readpicture(self, uri: str) -> types.ReadPictureResponse: ... async def readpicture(self, uri: str) -> types.ReadPictureResponse: ...
async def play(self) -> None: ... async def play(self) -> None: ...
async def pause(self, pause: Literal[1, 0, None] = None) -> None: async def pause(self, pause: Literal[1, 0, None] = None) -> None: