From a15f21b5dc841cecacefa9ebd69e4a97ccf85e59 Mon Sep 17 00:00:00 2001 From: Allen <63997543+aaw3@users.noreply.github.com> Date: Sun, 13 Nov 2022 15:36:11 -0600 Subject: [PATCH] Use mpd's readpicture as default, fallback to albumart --- bin/miniplayer | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/bin/miniplayer b/bin/miniplayer index a4d3389..be3bac9 100755 --- a/bin/miniplayer +++ b/bin/miniplayer @@ -499,14 +499,29 @@ class Player: A function that fetches the album art and saves it to self.album_art_loc """ + + readpictureFailed = False try: - albumart_data = self.client.albumart(song_file) + albumart_data = self.client.readpicture(song_file) with open(self.album_art_loc, "wb") as f: f.write(albumart_data["binary"]) except CommandError: - self.drawDefaultAlbumArt() + readpictureFailed = True + + + # If readpicture fails, try mpd's albumart function + if readpictureFailed: + try: + albumart_data = self.client.albumart(song_file) + + with open(self.album_art_loc, "wb") as f: + f.write(albumart_data["binary"]) + + except CommandError: + # If this also fails, just draw fallback image + self.drawDefaultAlbumArt() def drawDefaultAlbumArt(self):