mirror of
https://github.com/onyx-and-iris/vban-cmd-python.git
synced 2025-01-18 18:40:47 +00:00
refactor examples
add scripts to pyproject
This commit is contained in:
parent
87eb61170e
commit
44cd13aa48
@ -3,60 +3,61 @@ import logging
|
|||||||
import obsws_python as obs
|
import obsws_python as obs
|
||||||
import vban_cmd
|
import vban_cmd
|
||||||
|
|
||||||
|
logging.basicConfig(level=logging.INFO)
|
||||||
def on_start():
|
|
||||||
vban.strip[0].mute = True
|
|
||||||
vban.strip[1].B1 = True
|
|
||||||
vban.strip[2].B2 = True
|
|
||||||
|
|
||||||
|
|
||||||
def on_brb():
|
class Observer:
|
||||||
vban.strip[7].fadeto(0, 500)
|
def __init__(self, vban):
|
||||||
vban.bus[0].mute = True
|
self.vban = vban
|
||||||
|
self.client = obs.EventClient()
|
||||||
|
self.client.callback.register(self.on_current_program_scene_changed)
|
||||||
|
|
||||||
|
def on_start(self):
|
||||||
|
self.vban.strip[0].mute = True
|
||||||
|
self.vban.strip[1].B1 = True
|
||||||
|
self.vban.strip[2].B2 = True
|
||||||
|
|
||||||
|
def on_brb(self):
|
||||||
|
self.vban.strip[7].fadeto(0, 500)
|
||||||
|
self.vban.bus[0].mute = True
|
||||||
|
|
||||||
|
def on_end(self):
|
||||||
|
self.vban.apply(
|
||||||
|
{
|
||||||
|
"strip-0": {"mute": True},
|
||||||
|
"strip-1": {"mute": True, "B1": False},
|
||||||
|
"strip-2": {"mute": True, "B1": False},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
def on_live(self):
|
||||||
|
self.vban.strip[0].mute = False
|
||||||
|
self.vban.strip[7].fadeto(-6, 500)
|
||||||
|
self.vban.strip[7].A3 = True
|
||||||
|
|
||||||
|
def on_current_program_scene_changed(self, data):
|
||||||
|
def fget(scene):
|
||||||
|
run = {
|
||||||
|
"START": self.on_start,
|
||||||
|
"BRB": self.on_brb,
|
||||||
|
"END": self.on_end,
|
||||||
|
"LIVE": self.on_live,
|
||||||
|
}
|
||||||
|
return run.get(scene)
|
||||||
|
|
||||||
|
scene = data.scene_name
|
||||||
|
print(f"Switched to scene {scene}")
|
||||||
|
if fn := fget(scene):
|
||||||
|
fn()
|
||||||
|
|
||||||
|
|
||||||
def on_end():
|
def main():
|
||||||
vban.apply(
|
with vban_cmd.api("potato", sync=True) as vban:
|
||||||
{
|
obs = Observer(vban)
|
||||||
"strip-0": {"mute": True},
|
while cmd := input("<Enter> to exit\n"):
|
||||||
"strip-1": {"mute": True, "B1": False},
|
if not cmd:
|
||||||
"strip-2": {"mute": True, "B1": False},
|
break
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def on_live():
|
|
||||||
vban.strip[0].mute = False
|
|
||||||
vban.strip[7].fadeto(-6, 500)
|
|
||||||
vban.strip[7].A3 = True
|
|
||||||
|
|
||||||
|
|
||||||
def on_current_program_scene_changed(data):
|
|
||||||
scene = data.scene_name
|
|
||||||
print(f"Switched to scene {scene}")
|
|
||||||
|
|
||||||
match scene:
|
|
||||||
case "START":
|
|
||||||
on_start()
|
|
||||||
case "BRB":
|
|
||||||
on_brb()
|
|
||||||
case "END":
|
|
||||||
on_end()
|
|
||||||
case "LIVE":
|
|
||||||
on_live()
|
|
||||||
case _:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
logging.basicConfig(level=logging.INFO)
|
main()
|
||||||
|
|
||||||
kind_id = "potato"
|
|
||||||
|
|
||||||
with vban_cmd.api(kind_id, sync=True) as vban:
|
|
||||||
cl = obs.EventClient()
|
|
||||||
cl.callback.register(on_current_program_scene_changed)
|
|
||||||
|
|
||||||
while cmd := input("Press <Enter> to exit\n"):
|
|
||||||
if not cmd:
|
|
||||||
break
|
|
||||||
|
@ -2,6 +2,8 @@ import logging
|
|||||||
|
|
||||||
import vban_cmd
|
import vban_cmd
|
||||||
|
|
||||||
|
logging.basicConfig(level=logging.INFO)
|
||||||
|
|
||||||
|
|
||||||
class Observer:
|
class Observer:
|
||||||
def __init__(self, vban):
|
def __init__(self, vban):
|
||||||
@ -33,6 +35,4 @@ def main():
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
logging.basicConfig(level=logging.INFO)
|
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
@ -22,3 +22,7 @@ isort = "^5.10.1"
|
|||||||
[build-system]
|
[build-system]
|
||||||
requires = ["poetry-core>=1.0.0"]
|
requires = ["poetry-core>=1.0.0"]
|
||||||
build-backend = "poetry.core.masonry.api"
|
build-backend = "poetry.core.masonry.api"
|
||||||
|
|
||||||
|
[tool.poetry.scripts]
|
||||||
|
obs = "examples.obs.__main__:main"
|
||||||
|
observer = "examples.observer.__main__:main"
|
||||||
|
Loading…
Reference in New Issue
Block a user