|
|
|
|
@ -175,6 +175,21 @@ def pick_station_id_file():
@@ -175,6 +175,21 @@ 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 |
|
|
|
|
|
|
|
|
|
def set_rds(text: str): |
|
|
|
|
global rds_pipe |
|
|
|
|
try: |
|
|
|
|
@ -641,10 +656,15 @@ def worker():
@@ -641,10 +656,15 @@ 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}") |
|
|
|
|
queue.append(track) |
|
|
|
|
continue |
|
|
|
|
|
|
|
|
|
# Shuffle only when building the play order |
|
|
|
|
|