aboutsummaryrefslogtreecommitdiffstats
path: root/deckit/modules/obs.py
diff options
context:
space:
mode:
Diffstat (limited to 'deckit/modules/obs.py')
-rw-r--r--deckit/modules/obs.py15
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}