Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion bum/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ def get_args():
help="Use a remote server instead of localhost.",
default="localhost")

arg.add_argument("--no_server", action="store_true",
help="Don't run as a server; just download one cover and exit.")

arg.add_argument("--no_display",
action="store_true",
help="Only download album art, don't display.")
Expand Down Expand Up @@ -70,10 +73,13 @@ def main():
client = song.init(args.port, args.server)

while True:
song.get_art(args.cache_dir, args.size, args.default_cover, client)
got_cover = song.get_art(args.cache_dir, args.size, args.default_cover, client)
if not args.no_display:
display.launch(disp, args.cache_dir / "current.jpg")

if args.no_server:
exit(int(not got_cover))

client.send_idle()

if client.fetch_idle(["player"]):
Expand Down
10 changes: 8 additions & 2 deletions bum/song.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,18 @@ def get_art(cache_dir, size, default_cover, client):
print("album: Nothing currently playing.")
if default_cover:
shutil.copy(default_cover, cache_dir / "current.jpg")
return
return False

util.bytes_to_file(util.default_album_art(), cache_dir / "current.jpg")
return
return False

file_name = f"{song['artist']}_{song['album']}_{size}.jpg".replace("/", "")
file_name = cache_dir / file_name

if file_name.is_file():
shutil.copy(file_name, cache_dir / "current.jpg")
print("album: Found cached art.")
return True

else:
print("album: Downloading album art...")
Expand All @@ -56,3 +57,8 @@ def get_art(cache_dir, size, default_cover, client):
util.bytes_to_file(album_art, cache_dir / "current.jpg")

print(f"album: Swapped art to {song['artist']}, {song['album']}.")

if album_art:
return True
else:
return False