async def _fetch_artwork(self): playing = self.psm.playing resp = await self.psm.protocol.send_and_receive( messages.playback_queue_request(playing.location)) if not resp.HasField("type"): return None item = resp.inner().playbackQueue.contentItems[playing.location] return ArtworkInfo(item.artworkData, playing.metadata.artworkMIMEType)
async def _fetch_artwork(self, width, height): playing = self.psm.playing resp = await self.psm.protocol.send_and_receive( messages.playback_queue_request(playing.location, width, height)) if not resp.HasField("type"): return None item = resp.inner().playbackQueue.contentItems[playing.location] return ArtworkInfo( bytes=item.artworkData, mimetype=playing.metadata.artworkMIMEType, width=item.artworkDataWidth, height=item.artworkDataHeight, )
async def artwork(self): """Return artwork for what is currently playing (or None).""" playing = self.psm.playing metadata = playing.metadata if not metadata or not metadata.artworkAvailable: _LOGGER.debug('No artwork available') return None msg = messages.playback_queue_request(playing.location) resp = await self.psm.protocol.send_and_receive(msg) if resp.HasField('type'): item = resp.inner().playbackQueue.contentItems[playing.location] return ArtworkInfo(item.artworkData, metadata.artworkMIMEType) return None