diff --git a/app/__pycache__/__init__.cpython-314.pyc b/app/__pycache__/__init__.cpython-314.pyc new file mode 100644 index 0000000..597b17f Binary files /dev/null and b/app/__pycache__/__init__.cpython-314.pyc differ diff --git a/app/routes/__pycache__/api.cpython-314.pyc b/app/routes/__pycache__/api.cpython-314.pyc new file mode 100644 index 0000000..4395750 Binary files /dev/null and b/app/routes/__pycache__/api.cpython-314.pyc differ diff --git a/app/routes/api.py b/app/routes/api.py index 2436513..93c0a0f 100644 --- a/app/routes/api.py +++ b/app/routes/api.py @@ -12,6 +12,7 @@ from flask import Blueprint, jsonify, request, current_app import app.state as state from app.bluetooth.manager import MouldKing, advertiser, tracer from app.utils.helpers import load_default_sounds, load_soundboard_configs, load_soundboard_config +from config import Config logger = logging.getLogger(__name__) audio_lock = threading.Lock() @@ -43,8 +44,13 @@ def _load_sound(file_path): return snd -def _play_sound_entry(sound_entry, channel_req=None, loop_req=0): - sounds_dir = current_app.config['SOUNDS_DIR'] +def _play_sound_entry(sound_entry, channel_req=None, loop_req=0, sounds_dir=None): + if sounds_dir is None: + try: + sounds_dir = current_app.config['SOUNDS_DIR'] + except Exception: + sounds_dir = Config.SOUNDS_DIR + base_path = sound_entry.get('base_path') or sounds_dir file_path = os.path.join(base_path, sound_entry['file']) if not os.path.exists(file_path): @@ -120,7 +126,7 @@ def _auto_random_tick(): # Play one random sound sound_entry, err = _pick_random_sound() if sound_entry: - _play_sound_entry(sound_entry, sound_entry.get('channel'), sound_entry.get('loop')) + _play_sound_entry(sound_entry, sound_entry.get('channel'), sound_entry.get('loop'), Config.SOUNDS_DIR) # schedule next delay = rand_between(imin, imax) * 60 with auto_random_lock: