mirror of
https://github.com/onyx-and-iris/obsws-python.git
synced 2026-04-18 14:03:32 +00:00
EventsClient renamed to EventClient
remove getter, setter for send. add persistend data unit test add hotkey example default event sub now 0. explicitly define subs in event class. now subs can be set as kwarg
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from .events import EventsClient
|
||||
from .events import EventClient
|
||||
from .reqs import ReqClient
|
||||
|
||||
__ALL__ = ["ReqClient", "EventsClient"]
|
||||
|
||||
@@ -9,18 +9,13 @@ from random import randint
|
||||
import tomllib
|
||||
import websocket
|
||||
|
||||
Subs = IntEnum(
|
||||
"Subs",
|
||||
"general config scenes inputs transitions filters outputs sceneitems mediainputs vendors ui",
|
||||
start=0,
|
||||
)
|
||||
|
||||
|
||||
class ObsClient(object):
|
||||
DELAY = 0.001
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
defaultkwargs = {key: None for key in ["host", "port", "password"]}
|
||||
defaultkwargs["subs"] = 0
|
||||
kwargs = defaultkwargs | kwargs
|
||||
for attr, val in kwargs.items():
|
||||
setattr(self, attr, val)
|
||||
@@ -59,26 +54,12 @@ class ObsClient(object):
|
||||
).digest()
|
||||
).decode()
|
||||
|
||||
all_non_high_volume = (
|
||||
(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)
|
||||
)
|
||||
|
||||
payload = {
|
||||
"op": 1,
|
||||
"d": {
|
||||
"rpcVersion": 1,
|
||||
"authentication": auth,
|
||||
"eventSubscriptions": all_non_high_volume,
|
||||
"eventSubscriptions": self.subs,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -102,7 +83,4 @@ class ObsClient(object):
|
||||
}
|
||||
self.ws.send(json.dumps(payload))
|
||||
response = json.loads(self.ws.recv())
|
||||
while "requestId" not in response["d"]:
|
||||
response = json.loads(self.ws.recv())
|
||||
time.sleep(self.DELAY)
|
||||
return response["d"]
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import json
|
||||
import time
|
||||
from enum import IntEnum
|
||||
from threading import Thread
|
||||
|
||||
from .baseclient import ObsClient
|
||||
@@ -11,11 +12,30 @@ 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 EventsClient(object):
|
||||
|
||||
class EventClient(object):
|
||||
DELAY = 0.001
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
kwargs["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)
|
||||
)
|
||||
self.base_client = ObsClient(**kwargs)
|
||||
self.base_client.authenticate()
|
||||
self.callback = Callback()
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user