mirror of
https://github.com/onyx-and-iris/obsws-python.git
synced 2024-11-22 12:50:53 +00:00
Merge pull request #20 from onyx-and-iris/dev
add conn info to __repr__ methods, lower required python ver to 3.9 + other small changes
This commit is contained in:
commit
ef0f770c0c
@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
# A Python SDK for OBS Studio WebSocket v5.0
|
# A Python SDK for OBS Studio WebSocket v5.0
|
||||||
|
|
||||||
This is a wrapper around OBS Websocket.
|
|
||||||
Not all endpoints in the official documentation are implemented.
|
Not all endpoints in the official documentation are implemented.
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
@ -13,7 +12,7 @@ Not all endpoints in the official documentation are implemented.
|
|||||||
- [OBS Studio](https://obsproject.com/)
|
- [OBS Studio](https://obsproject.com/)
|
||||||
- [OBS Websocket v5 Plugin](https://github.com/obsproject/obs-websocket/releases/tag/5.0.0)
|
- [OBS Websocket v5 Plugin](https://github.com/obsproject/obs-websocket/releases/tag/5.0.0)
|
||||||
- With the release of OBS Studio version 28, Websocket plugin is included by default. But it should be manually installed for earlier versions of OBS.
|
- With the release of OBS Studio version 28, Websocket plugin is included by default. But it should be manually installed for earlier versions of OBS.
|
||||||
- Python 3.10 or greater
|
- Python 3.9 or greater
|
||||||
|
|
||||||
### How to install using pip
|
### How to install using pip
|
||||||
|
|
||||||
@ -27,7 +26,7 @@ By default the clients connect with parameters:
|
|||||||
|
|
||||||
- `host`: "localhost"
|
- `host`: "localhost"
|
||||||
- `port`: 4455
|
- `port`: 4455
|
||||||
- `password`: None
|
- `password`: ""
|
||||||
|
|
||||||
You may override these parameters by storing them in a toml config file or passing them as keyword arguments.
|
You may override these parameters by storing them in a toml config file or passing them as keyword arguments.
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
from .enum import Subs
|
|
||||||
from .events import EventClient
|
from .events import EventClient
|
||||||
from .reqs import ReqClient
|
from .reqs import ReqClient
|
||||||
|
from .subs import Subs
|
||||||
from .version import version as __version__
|
from .version import version as __version__
|
||||||
|
|
||||||
__ALL__ = ["ReqClient", "EventClient", "Subs"]
|
__ALL__ = ["ReqClient", "EventClient", "Subs"]
|
||||||
|
@ -14,7 +14,7 @@ class ObsClient:
|
|||||||
logger = logging.getLogger("baseclient.obsclient")
|
logger = logging.getLogger("baseclient.obsclient")
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
defaultkwargs = {"host": "localhost", "port": 4455, "password": None, "subs": 0}
|
defaultkwargs = {"host": "localhost", "port": 4455, "password": "", "subs": 0}
|
||||||
if not any(key in kwargs for key in ("host", "port", "password")):
|
if not any(key in kwargs for key in ("host", "port", "password")):
|
||||||
kwargs |= self._conn_from_toml()
|
kwargs |= self._conn_from_toml()
|
||||||
kwargs = defaultkwargs | kwargs
|
kwargs = defaultkwargs | kwargs
|
||||||
@ -22,7 +22,7 @@ class ObsClient:
|
|||||||
setattr(self, attr, val)
|
setattr(self, attr, val)
|
||||||
|
|
||||||
self.logger.info(
|
self.logger.info(
|
||||||
"Connecting with parameters: {host} {port} {password} {subs}".format(
|
"Connecting with parameters: host='{host}' port={port} password='{password}' subs={subs}".format(
|
||||||
**self.__dict__
|
**self.__dict__
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -5,7 +5,7 @@ from threading import Thread
|
|||||||
|
|
||||||
from .baseclient import ObsClient
|
from .baseclient import ObsClient
|
||||||
from .callback import Callback
|
from .callback import Callback
|
||||||
from .enum import Subs
|
from .subs import Subs
|
||||||
|
|
||||||
"""
|
"""
|
||||||
A class to interact with obs-websocket events
|
A class to interact with obs-websocket events
|
||||||
@ -28,6 +28,13 @@ class EventClient:
|
|||||||
self.subscribe()
|
self.subscribe()
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
|
return type(
|
||||||
|
self
|
||||||
|
).__name__ + "(host='{host}', port={port}, password='{password}', subs={subs})".format(
|
||||||
|
**self.base_client.__dict__,
|
||||||
|
)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
return type(self).__name__
|
return type(self).__name__
|
||||||
|
|
||||||
def subscribe(self):
|
def subscribe(self):
|
||||||
|
@ -26,6 +26,13 @@ class ReqClient:
|
|||||||
self.base_client.ws.close()
|
self.base_client.ws.close()
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
|
return type(
|
||||||
|
self
|
||||||
|
).__name__ + "(host='{host}', port={port}, password='{password}')".format(
|
||||||
|
**self.base_client.__dict__,
|
||||||
|
)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
return type(self).__name__
|
return type(self).__name__
|
||||||
|
|
||||||
def send(self, param, data=None, raw=False):
|
def send(self, param, data=None, raw=False):
|
||||||
|
@ -1 +1 @@
|
|||||||
version = "1.3.0"
|
version = "1.4.0"
|
||||||
|
@ -8,7 +8,7 @@ dynamic = ["version"]
|
|||||||
description = "A Python SDK for OBS Studio WebSocket v5.0"
|
description = "A Python SDK for OBS Studio WebSocket v5.0"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
license = "GPL-3.0-only"
|
license = "GPL-3.0-only"
|
||||||
requires-python = ">=3.10"
|
requires-python = ">=3.9"
|
||||||
authors = [
|
authors = [
|
||||||
{ name = "Adem Atikturk", email = "aatikturk@gmail.com" },
|
{ name = "Adem Atikturk", email = "aatikturk@gmail.com" },
|
||||||
]
|
]
|
||||||
@ -37,7 +37,18 @@ include = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[tool.hatch.envs.e.scripts]
|
[tool.hatch.envs.e.scripts]
|
||||||
events = "py {root}\\examples\\events\\."
|
events = "python {root}\\examples\\events\\."
|
||||||
hotkeys = "py {root}\\examples\\hotkeys\\."
|
hotkeys = "python {root}\\examples\\hotkeys\\."
|
||||||
levels = "py {root}\\examples\\levels\\."
|
levels = "python {root}\\examples\\levels\\."
|
||||||
scene_rotate = "py {root}\\examples\\scene_rotate\\."
|
scene_rotate = "python {root}\\examples\\scene_rotate\\."
|
||||||
|
|
||||||
|
[tool.hatch.envs.test]
|
||||||
|
dependencies = [
|
||||||
|
"pytest",
|
||||||
|
]
|
||||||
|
|
||||||
|
[tool.hatch.envs.test.scripts]
|
||||||
|
run = 'pytest -v'
|
||||||
|
|
||||||
|
[[tool.hatch.envs.test.matrix]]
|
||||||
|
python = ["39", "310", "311"]
|
||||||
|
2
setup.py
2
setup.py
@ -40,7 +40,7 @@ EXTRAS_REQUIRE = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Python version requirement
|
# Python version requirement
|
||||||
PYTHON_REQUIRES = ">=3.10"
|
PYTHON_REQUIRES = ">=3.9"
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name=PACKAGE_NAME,
|
name=PACKAGE_NAME,
|
||||||
|
@ -13,4 +13,7 @@ def teardown_module():
|
|||||||
req_cl.remove_scene("START_TEST")
|
req_cl.remove_scene("START_TEST")
|
||||||
req_cl.remove_scene("BRB_TEST")
|
req_cl.remove_scene("BRB_TEST")
|
||||||
req_cl.remove_scene("END_TEST")
|
req_cl.remove_scene("END_TEST")
|
||||||
|
resp = req_cl.get_studio_mode_enabled()
|
||||||
|
if resp.studio_mode_enabled:
|
||||||
|
req_cl.set_studio_mode_enabled(False)
|
||||||
req_cl.base_client.ws.close()
|
req_cl.base_client.ws.close()
|
||||||
|
Loading…
Reference in New Issue
Block a user