Skip to content

Commit

Permalink
Add default album art for dylanaraps#11
Browse files Browse the repository at this point in the history
  • Loading branch information
Gadgetoid committed Sep 30, 2019
1 parent e951587 commit 5426c3c
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions bum/song.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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']}.")

0 comments on commit 5426c3c

Please sign in to comment.