Browse Source

trim out file path and extension for display purposes

master
parent
commit
71e218fc2d
  1. 12
      music-api.py

12
music-api.py

@ -358,6 +358,14 @@ def extract_album_art(path: str, rel_path: str, timeout: int = 10):
return None return None
def display_title(path):
"""Convert 'dir/a/b/Song - Title.ext''Song - Title'."""
if not path:
return None
base = os.path.basename(path)
title, _ = os.path.splitext(base)
return title
# ----------------------------- # -----------------------------
# Pump helper for decoder -> wrapper # Pump helper for decoder -> wrapper
# ----------------------------- # -----------------------------
@ -786,7 +794,7 @@ def album_art(name):
@app.get("/queue") @app.get("/queue")
def get_queue(): def get_queue():
with queue_lock: with queue_lock:
return jsonify(list(queue)) return jsonify([display_title(item) for item in queue])
@app.post("/queue") @app.post("/queue")
def add_to_queue(): def add_to_queue():
@ -813,7 +821,7 @@ def now_playing():
art_name = TRACKS[current_track].get("album_art") art_name = TRACKS[current_track].get("album_art")
if art_name: if art_name:
art = f"/album_art/{art_name}" art = f"/album_art/{art_name}"
return jsonify({"track": current_track, "album_art": art}) return jsonify({"track": display_title(current_track), "album_art": art})
@app.post("/shuffle") @app.post("/shuffle")
def set_shuffle(): def set_shuffle():

Loading…
Cancel
Save