|
|
|
|
@ -175,20 +175,11 @@ def pick_station_id_file():
@@ -175,20 +175,11 @@ def pick_station_id_file():
|
|
|
|
|
return None |
|
|
|
|
return os.path.join(STATION_ID_DIR, random.choice(files)) |
|
|
|
|
|
|
|
|
|
### FIXME: |
|
|
|
|
def pick_random_track(): |
|
|
|
|
conn = sqlite3.connect(DB_PATH) |
|
|
|
|
c = conn.cursor() |
|
|
|
|
c.execute(""" |
|
|
|
|
SELECT path |
|
|
|
|
FROM tracks |
|
|
|
|
WHERE is_station_id = 0 |
|
|
|
|
ORDER BY RANDOM() |
|
|
|
|
LIMIT 1 |
|
|
|
|
""") |
|
|
|
|
row = c.fetchone() |
|
|
|
|
conn.close() |
|
|
|
|
return row[0] if row else None |
|
|
|
|
"""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): |
|
|
|
|
global rds_pipe |
|
|
|
|
@ -439,9 +430,6 @@ def restart_radio_chain():
@@ -439,9 +430,6 @@ def restart_radio_chain():
|
|
|
|
|
print("[WATCHDOG] Restarting pifmadv") |
|
|
|
|
start_pifm() |
|
|
|
|
|
|
|
|
|
print("[WATCHDOG] Restarting persistent WAV wrapper") |
|
|
|
|
start_persistent_wav() |
|
|
|
|
|
|
|
|
|
# Your addition: broadcast station ID |
|
|
|
|
id_file = pick_station_id_file() |
|
|
|
|
if id_file: |
|
|
|
|
@ -656,17 +644,16 @@ def worker():
@@ -656,17 +644,16 @@ def worker():
|
|
|
|
|
empty = True |
|
|
|
|
else: |
|
|
|
|
empty = False |
|
|
|
|
### FIXME: |
|
|
|
|
|
|
|
|
|
if empty: |
|
|
|
|
write_silence(0.25) |
|
|
|
|
time.sleep(0.5) |
|
|
|
|
# Ensure the queue is never empty |
|
|
|
|
track = pick_random_track() |
|
|
|
|
if track: |
|
|
|
|
print(f"[WORKER] Queue empty — adding random track: {track}") |
|
|
|
|
with queue_lock: |
|
|
|
|
queue.append(track) |
|
|
|
|
continue |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Shuffle only when building the play order |
|
|
|
|
if shuffle_mode: |
|
|
|
|
with queue_lock: |
|
|
|
|
|