From 5228b809edd681e8ae60f50e0b585591c60b57c6 Mon Sep 17 00:00:00 2001 From: badaix Date: Wed, 19 May 2021 09:09:12 +0200 Subject: [PATCH] Add album art --- control/meta_mpd.py | 8 ++++++++ control/snapcast_mpris.py | 3 +++ 2 files changed, 11 insertions(+) diff --git a/control/meta_mpd.py b/control/meta_mpd.py index f3d21833..5fcfebfb 100755 --- a/control/meta_mpd.py +++ b/control/meta_mpd.py @@ -397,6 +397,14 @@ class MPDWrapper(object): print("Can't cast value %r to %s" % (value, tag_mapping[key][1])) + if 'title' in mpd_meta and 'album' in mpd_meta: + result = musicbrainzngs.search_releases(artist=mpd_meta['title'], release=mpd_meta['album'], + limit=1) + if result['release-list']: + snapmeta['artUrl'] = f"http://coverartarchive.org/release/{result['release-list'][0]['id']}/front-250" + print(snapmeta['artUrl']) + + r = requests.post('http://127.0.0.1:1780/jsonrpc', json={"id": 4, "jsonrpc": "2.0", "method": "Stream.SetMeta", "params": { "id": "Spotify", "meta": snapmeta}}) print(r) diff --git a/control/snapcast_mpris.py b/control/snapcast_mpris.py index 00692039..02f4984e 100755 --- a/control/snapcast_mpris.py +++ b/control/snapcast_mpris.py @@ -407,6 +407,9 @@ class MPDWrapper(object): self._metadata = {} self._metadata['xesam:artist'] = self.__getValue(meta, 'artist', 'Unknown Artist') self._metadata['xesam:title'] = self.__getValue(meta, 'title', 'Unknown Title') + if 'artUrl' in meta: + self._metadata['mpris:artUrl'] = meta['artUrl'] + self.notify_about_track(self._metadata) new_meta = self._dbus_service.update_property('org.mpris.MediaPlayer2.Player',