Compare commits
No commits in common. "37166e146de459930575c5f5f625075c96748cb3" and "8ad255856e9bb2b538f68410816a66db51217bc3" have entirely different histories.
37166e146d
...
8ad255856e
4 changed files with 6 additions and 18 deletions
|
@ -49,7 +49,7 @@ class MpdArtworkCache:
|
|||
return None
|
||||
|
||||
async def cache_artwork(self, song: CurrentSongResponse) -> None:
|
||||
art = ArtCacheEntry(data=await self.mpd.get_art(song["file"]))
|
||||
art = ArtCacheEntry(data=await self.mpd.readpicture(song["file"]))
|
||||
try:
|
||||
await self.album_cache.add(calc_album_key(song), art, ttl=CACHE_TTL)
|
||||
except ValueError:
|
||||
|
|
|
@ -95,19 +95,6 @@ class MpdStateListener(Player):
|
|||
print(song)
|
||||
listener.update(song)
|
||||
|
||||
async def get_art(self, file: str) -> bytes | None:
|
||||
picture = await self.readpicture(file)
|
||||
if picture:
|
||||
return picture
|
||||
return await self.albumart(file)
|
||||
|
||||
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)
|
||||
|
|
|
@ -2,9 +2,11 @@ from typing import Literal, NotRequired, Protocol, TypedDict
|
|||
|
||||
|
||||
class MpdStateHandler(Protocol):
|
||||
async def get_art(self, file: str) -> bytes | None: ...
|
||||
async def readpicture(self, file: str) -> bytes | None:
|
||||
...
|
||||
|
||||
async def refresh(self) -> None: ...
|
||||
async def refresh(self) -> None:
|
||||
...
|
||||
|
||||
|
||||
BooleanFlag = Literal["0", "1"]
|
||||
|
|
|
@ -13,7 +13,6 @@ 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:
|
||||
|
|
Loading…
Reference in a new issue