diff options
| author | Danilo M. <danix@danix.xyz> | 2026-11-09 19:08:49 +0100 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-11-09 19:08:49 +0100 |
| commit | 4632e6183d38bfd239f066d7e9698f3d118a3f77 (patch) | |
| tree | 8d458ea7395c6e52186f0bfb38344dbc84f68cbe /deckit/modules | |
| parent | c906d90dcf0abdfb347bd67d6f33a2c45ae32e66 (diff) | |
| download | deck-it-4632e6183d38bfd239f066d7e9698f3d118a3f77.tar.gz deck-it-4632e6183d38bfd239f066d7e9698f3d118a3f77.zip | |
fix: use OBS's stored password and explain auth failures
Diffstat (limited to 'deckit/modules')
| -rw-r--r-- | deckit/modules/obs.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/deckit/modules/obs.py b/deckit/modules/obs.py index 96217c4..04c49ef 100644 --- a/deckit/modules/obs.py +++ b/deckit/modules/obs.py @@ -1,10 +1,22 @@ """OBS stream-deck: recording, scenes, audio channels, transitions and sources.""" +import json import threading +from pathlib import Path from ..module import Module, ModuleError from ..obsclient import ObsClient +OBS_CONFIG = Path.home() / ".config" / "obs-studio" / "plugin_config" / "obs-websocket" / "config.json" + + +def _obs_password(path=OBS_CONFIG) -> str: + """OBS stores its websocket password in plain text here.""" + try: + return json.loads(Path(path).read_text()).get("server_password") or "" + except (OSError, ValueError): + return "" + AUDIO_KINDS = { "pulse_input_capture", "pulse_output_capture", "alsa_input_capture", "alsa_output_capture", "wasapi_input_capture", "wasapi_output_capture", "coreaudio_input_capture", "coreaudio_output_capture", @@ -15,7 +27,8 @@ AUDIO_KINDS = { def make(cfg: dict) -> Module: o = cfg.get("obs", {}) client = cfg.get("client") or ObsClient( - host=o.get("host", "127.0.0.1"), port=o.get("port", 4455), password=o.get("password", "")) + host=o.get("host", "127.0.0.1"), port=o.get("port", 4455), + password=o.get("password") or _obs_password()) lock = threading.Lock() stop = threading.Event() last_error = {"msg": None} |
