example now registeres on_exit_started

script will now end when OBS is closed

filter out all logs but `vban_cmd.iremote`

setup.py added
This commit is contained in:
onyx-and-iris 2023-06-25 14:49:07 +01:00
parent 7a3abfc372
commit ca9a31c94a
3 changed files with 48 additions and 11 deletions

View File

@ -40,10 +40,12 @@ Make sure you have established a working connection to OBS and the remote Voicem
Run the script, change OBS scenes and watch Voicemeeter parameters change.
Pressing `<Enter>` will exit.
Closing OBS will end the script.
## Notes
All but `vban_cmd.iremote` logs are filtered out. Log in DEBUG mode.
This script can be run from a Linux host since the vban-cmd interface relies on UDP packets and obsws-python runs over websockets.
You could for example, set this up to run in the background on a home server such as a Raspberry Pi.

View File

@ -1,16 +1,41 @@
import logging
import time
from logging import config
import obsws_python as obsws
import obsws_python as obs
import vban_cmd
logging.basicConfig(level=logging.INFO)
config.dictConfig(
{
"version": 1,
"formatters": {
"standard": {
"format": "%(asctime)s,%(msecs)d %(name)s %(levelname)s %(message)s"
}
},
"handlers": {
"stream": {
"level": "DEBUG",
"class": "logging.StreamHandler",
"formatter": "standard",
}
},
"loggers": {"vban_cmd.iremote": {"handlers": ["stream"], "level": "DEBUG"}},
}
)
class Observer:
def __init__(self, vban):
self.vban = vban
self.client = obs.EventClient()
self.client.callback.register(self.on_current_program_scene_changed)
self.client = obsws.EventClient()
self.client.callback.register(
(
self.on_current_program_scene_changed,
self.on_exit_started,
)
)
self.is_running = True
def on_start(self):
self.vban.strip[0].mute = True
@ -50,13 +75,16 @@ class Observer:
if fn := fget(scene):
fn()
def on_exit_started(self, _):
self.client.unsubscribe()
self.is_running = False
def main():
with vban_cmd.api("potato", sync=True) as vban:
obs = Observer(vban)
while cmd := input("<Enter> to exit\n"):
if not cmd:
break
with vban_cmd.api("potato") as vban:
observer = Observer(vban)
while observer.is_running:
time.sleep(0.1)
if __name__ == "__main__":

7
examples/obs/setup.py Normal file
View File

@ -0,0 +1,7 @@
from setuptools import setup
setup(
name="obs",
description="OBS Example",
install_requires=["obsws-python"],
)