Compare commits

...

1 Commits

  1. 18
      music-api.py

18
music-api.py

@ -175,6 +175,12 @@ def pick_station_id_file():
return None return None
return os.path.join(STATION_ID_DIR, random.choice(files)) return os.path.join(STATION_ID_DIR, random.choice(files))
def pick_random_track():
"""Return a random music track (relative path) from TRACKS."""
if not TRACKS:
return None
return random.choice(list(TRACKS.keys()))
def set_rds(text: str): def set_rds(text: str):
global rds_pipe global rds_pipe
try: try:
@ -639,10 +645,14 @@ def worker():
else: else:
empty = False empty = False
if empty: if empty:
write_silence(0.25) track = pick_random_track()
time.sleep(0.5) if track:
continue print(f"[WORKER] Queue empty — adding random track: {track}")
with queue_lock:
queue.append(track)
continue
# Shuffle only when building the play order # Shuffle only when building the play order
if shuffle_mode: if shuffle_mode:

Loading…
Cancel
Save