From 5426c3cc0064872a42b3325c3ff2a6457a19fcfb Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Mon, 30 Sep 2019 14:35:47 +0100 Subject: [PATCH] Add default album art for dylanaraps/bum#11 --- bum/song.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/bum/song.py b/bum/song.py index c770187..8b4cd57 100644 --- a/bum/song.py +++ b/bum/song.py @@ -43,7 +43,7 @@ def get_art(self, cache_dir, size): song = self.currentsong() if len(song) < 2: print("album: Nothing currently playing.") - return + util.bytes_to_file(util.default_cover_art, cache_dir / "current.jpg") file_name = f"{song['artist']}_{song['album']}_{size}.jpg".replace("/", "") file_name = cache_dir / file_name @@ -58,8 +58,10 @@ def get_art(self, cache_dir, size): brainz.init() album_art = brainz.get_cover(song, size) - if album_art: - util.bytes_to_file(album_art, cache_dir / file_name) - util.bytes_to_file(album_art, cache_dir / "current.jpg") + if not album_art: + album_art = util.default_cover_art() - print(f"album: Swapped art to {song['artist']}, {song['album']}.") + util.bytes_to_file(album_art, cache_dir / file_name) + util.bytes_to_file(album_art, cache_dir / "current.jpg") + + print(f"album: Swapped art to {song['artist']}, {song['album']}.")