diff --git a/README.md b/README.md index fb39ca5..b1d2a44 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,6 @@ # 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. ## Requirements @@ -13,7 +12,7 @@ Not all endpoints in the official documentation are implemented. - [OBS Studio](https://obsproject.com/) - [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. -- Python 3.10 or greater +- Python 3.9 or greater ### How to install using pip @@ -27,7 +26,7 @@ By default the clients connect with parameters: - `host`: "localhost" - `port`: 4455 -- `password`: None +- `password`: "" You may override these parameters by storing them in a toml config file or passing them as keyword arguments. diff --git a/obsws_python/__init__.py b/obsws_python/__init__.py index 80251d6..b0e6d73 100644 --- a/obsws_python/__init__.py +++ b/obsws_python/__init__.py @@ -1,6 +1,6 @@ -from .enum import Subs from .events import EventClient from .reqs import ReqClient +from .subs import Subs from .version import version as __version__ __ALL__ = ["ReqClient", "EventClient", "Subs"] diff --git a/obsws_python/baseclient.py b/obsws_python/baseclient.py index 273e96b..e1dfc52 100644 --- a/obsws_python/baseclient.py +++ b/obsws_python/baseclient.py @@ -14,7 +14,7 @@ class ObsClient: logger = logging.getLogger("baseclient.obsclient") 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")): kwargs |= self._conn_from_toml() kwargs = defaultkwargs | kwargs @@ -22,7 +22,7 @@ class ObsClient: setattr(self, attr, val) 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__ ) ) diff --git a/obsws_python/events.py b/obsws_python/events.py index 0771e26..9a942e6 100644 --- a/obsws_python/events.py +++ b/obsws_python/events.py @@ -5,7 +5,7 @@ from threading import Thread from .baseclient import ObsClient from .callback import Callback -from .enum import Subs +from .subs import Subs """ A class to interact with obs-websocket events @@ -28,6 +28,13 @@ class EventClient: self.subscribe() 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__ def subscribe(self): diff --git a/obsws_python/reqs.py b/obsws_python/reqs.py index 58dc888..f823431 100644 --- a/obsws_python/reqs.py +++ b/obsws_python/reqs.py @@ -26,6 +26,13 @@ class ReqClient: self.base_client.ws.close() 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__ def send(self, param, data=None, raw=False): diff --git a/obsws_python/enum.py b/obsws_python/subs.py similarity index 100% rename from obsws_python/enum.py rename to obsws_python/subs.py diff --git a/obsws_python/version.py b/obsws_python/version.py index d28b3dd..d619c75 100644 --- a/obsws_python/version.py +++ b/obsws_python/version.py @@ -1 +1 @@ -version = "1.3.0" +version = "1.4.0" diff --git a/pyproject.toml b/pyproject.toml index 812c68a..287fdf5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ dynamic = ["version"] description = "A Python SDK for OBS Studio WebSocket v5.0" readme = "README.md" license = "GPL-3.0-only" -requires-python = ">=3.10" +requires-python = ">=3.9" authors = [ { name = "Adem Atikturk", email = "aatikturk@gmail.com" }, ] @@ -37,7 +37,18 @@ include = [ ] [tool.hatch.envs.e.scripts] -events = "py {root}\\examples\\events\\." -hotkeys = "py {root}\\examples\\hotkeys\\." -levels = "py {root}\\examples\\levels\\." -scene_rotate = "py {root}\\examples\\scene_rotate\\." +events = "python {root}\\examples\\events\\." +hotkeys = "python {root}\\examples\\hotkeys\\." +levels = "python {root}\\examples\\levels\\." +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"] diff --git a/setup.py b/setup.py index 4b369e1..b157c07 100644 --- a/setup.py +++ b/setup.py @@ -40,7 +40,7 @@ EXTRAS_REQUIRE = { } # Python version requirement -PYTHON_REQUIRES = ">=3.10" +PYTHON_REQUIRES = ">=3.9" setup( name=PACKAGE_NAME, diff --git a/tests/__init__.py b/tests/__init__.py index b1e7d9c..a20f785 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -13,4 +13,7 @@ def teardown_module(): req_cl.remove_scene("START_TEST") req_cl.remove_scene("BRB_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()