From d4ae72dee5371ce841fce307a3643e08e6487ba2 Mon Sep 17 00:00:00 2001 From: onyx-and-iris <75868496+onyx-and-iris@users.noreply.github.com> Date: Wed, 26 Oct 2022 11:08:24 +0100 Subject: [PATCH] Subs moved into enum.py Subs now exported --- obsws_python/__init__.py | 3 ++- obsws_python/enum.py | 43 ++++++++++++++++++++++++++++++++++++++++ obsws_python/events.py | 24 ++-------------------- 3 files changed, 47 insertions(+), 23 deletions(-) create mode 100644 obsws_python/enum.py diff --git a/obsws_python/__init__.py b/obsws_python/__init__.py index 6ab08c5..d54af06 100644 --- a/obsws_python/__init__.py +++ b/obsws_python/__init__.py @@ -1,4 +1,5 @@ +from .enum import Subs from .events import EventClient from .reqs import ReqClient -__ALL__ = ["ReqClient", "EventClient"] +__ALL__ = ["ReqClient", "EventClient", "Subs"] diff --git a/obsws_python/enum.py b/obsws_python/enum.py new file mode 100644 index 0000000..b3c4b7e --- /dev/null +++ b/obsws_python/enum.py @@ -0,0 +1,43 @@ +from enum import IntFlag + + +class Subs(IntFlag): + GENERAL = 1 << 0 + CONFIG = 1 << 1 + SCENES = 1 << 2 + INPUTS = 1 << 3 + TRANSITIONS = 1 << 4 + FILTERS = 1 << 5 + OUTPUTS = 1 << 6 + SCENEITEMS = 1 << 7 + MEDIAINPUTS = 1 << 8 + VENDORS = 1 << 9 + UI = 1 << 10 + + LOW_VOLUME = ( + GENERAL + | CONFIG + | SCENES + | INPUTS + | TRANSITIONS + | FILTERS + | OUTPUTS + | SCENEITEMS + | MEDIAINPUTS + | VENDORS + | UI + ) + + INPUTVOLUMEMETERS = 1 << 16 + INPUTACTIVESTATECHANGED = 1 << 17 + INPUTSHOWSTATECHANGED = 1 << 18 + SCENEITEMTRANSFORMCHANGED = 1 << 19 + + HIGH_VOLUME = ( + INPUTVOLUMEMETERS + | INPUTACTIVESTATECHANGED + | INPUTSHOWSTATECHANGED + | SCENEITEMTRANSFORMCHANGED + ) + + ALL = LOW_VOLUME | HIGH_VOLUME diff --git a/obsws_python/events.py b/obsws_python/events.py index a2f07bc..0771e26 100644 --- a/obsws_python/events.py +++ b/obsws_python/events.py @@ -1,11 +1,11 @@ import json import logging import time -from enum import IntEnum from threading import Thread from .baseclient import ObsClient from .callback import Callback +from .enum import Subs """ A class to interact with obs-websocket events @@ -13,33 +13,13 @@ defined in official github repo https://github.com/obsproject/obs-websocket/blob/master/docs/generated/protocol.md#events """ -Subs = IntEnum( - "Subs", - "general config scenes inputs transitions filters outputs sceneitems mediainputs vendors ui", - start=0, -) - class EventClient: logger = logging.getLogger("events.eventclient") DELAY = 0.001 def __init__(self, **kwargs): - defaultkwargs = { - "subs": ( - (1 << Subs.general) - | (1 << Subs.config) - | (1 << Subs.scenes) - | (1 << Subs.inputs) - | (1 << Subs.transitions) - | (1 << Subs.filters) - | (1 << Subs.outputs) - | (1 << Subs.sceneitems) - | (1 << Subs.mediainputs) - | (1 << Subs.vendors) - | (1 << Subs.ui) - ) - } + defaultkwargs = {"subs": Subs.LOW_VOLUME} kwargs = defaultkwargs | kwargs self.base_client = ObsClient(**kwargs) if self.base_client.authenticate():