Merge pull request #6 from onyx-and-iris/main

support python 3.10
This commit is contained in:
Adem 2022-08-31 23:01:23 +03:00 committed by GitHub
commit dc6829434c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 68 additions and 15 deletions

1
.gitignore vendored
View File

@ -20,7 +20,6 @@ wheels/
*.egg-info/ *.egg-info/
.installed.cfg .installed.cfg
*.egg *.egg
setup.py
MANIFEST MANIFEST
# Unit test / coverage reports # Unit test / coverage reports

View File

@ -12,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)
- Python 3.11 or greater - Python 3.10 or greater
### How to install using pip ### How to install using pip
@ -44,7 +44,7 @@ Import and start using, keyword arguments are as follows:
Example `__main__.py`: Example `__main__.py`:
```python ```python
from obsstudio_sdk import reqs as obs import obsstudio_sdk as obs
# pass conn info if not in config.toml # pass conn info if not in config.toml
cl = obs.ReqClient(host='localhost', port=4455, password='mystrongpass') cl = obs.ReqClient(host='localhost', port=4455, password='mystrongpass')
@ -60,15 +60,14 @@ Method names for requests match the API calls but snake cased.
example: example:
```python ```python
from obsstudio_sdk import reqs as obs # load conn info from config.toml
cl = obs.ReqClient(host='localhost', port=4455, password='mystrongpass') cl = obs.ReqClient()
# GetVersion # GetVersion
resp = cl.get_version() resp = cl.get_version()
# SetCurrentProgramScene # SetCurrentProgramScene
cl.set_current_program_scene() cl.set_current_program_scene("BRB")
``` ```
For a full list of requests refer to [Requests](https://github.com/obsproject/obs-websocket/blob/master/docs/generated/protocol.md#requests) For a full list of requests refer to [Requests](https://github.com/obsproject/obs-websocket/blob/master/docs/generated/protocol.md#requests)
@ -80,7 +79,8 @@ When registering a function callback use the name of the expected API event in s
example: example:
```python ```python
cl = EventClient() # load conn info from config.toml
cl = obs.EventClient()
def scene_created(data): def scene_created(data):
... ...

16
examples/events/README.md Normal file
View File

@ -0,0 +1,16 @@
## About
Registers a list of callback functions to hook into OBS events.
## Use
Simply run the code and trigger the events, press `<Enter>` to exit.
This example assumes the existence of a `config.toml`, placed next to `__main__.py`:
```toml
[connection]
host = "localhost"
port = 4455
password = "mystrongpass"
```

View File

@ -0,0 +1,20 @@
## About
Sets up some hotkeys to trigger certain actions. Registers a callback function to notify of scene switch event.
Requires [Python Keyboard library](https://github.com/boppreh/keyboard).
## Use
Simply run the code and press the assigned hotkeys. Press `ctrl+enter` to exit.
This example assumes the existence of a `config.toml`, placed next to `__main__.py`:
```toml
[connection]
host = "localhost"
port = 4455
password = "mystrongpass"
```
It also assumes the existence of scenes named `START`, `BRB` and `END`.

View File

@ -0,0 +1,14 @@
## About
Collects the names of all available scenes, rotates through them and prints their name.
## Use
This example assumes the existence of a `config.toml`, placed next to `__main__.py`:
```toml
[connection]
host = "localhost"
port = 4455
password = "mystrongpass"
```

View File

@ -7,9 +7,9 @@ def main():
resp = cl.get_scene_list() resp = cl.get_scene_list()
scenes = reversed(tuple(di.get("sceneName") for di in resp.scenes)) scenes = reversed(tuple(di.get("sceneName") for di in resp.scenes))
for sc in scenes: for scene in scenes:
print(f"Switching to scene {sc}") print(f"Switching to scene {scene}")
cl.set_current_program_scene(sc) cl.set_current_program_scene(scene)
time.sleep(0.5) time.sleep(0.5)

View File

@ -4,7 +4,11 @@ import json
from pathlib import Path from pathlib import Path
from random import randint from random import randint
import tomllib try:
import tomllib
except ModuleNotFoundError:
import tomli as tomllib
import websocket import websocket

View File

@ -5,7 +5,7 @@ from setuptools import find_packages, setup
HERE = pathlib.Path(__file__).parent HERE = pathlib.Path(__file__).parent
VERSION = "1.0.2" VERSION = "1.0.3"
PACKAGE_NAME = "obsstudio_sdk" PACKAGE_NAME = "obsstudio_sdk"
AUTHOR = "Adem Atikturk" AUTHOR = "Adem Atikturk"
AUTHOR_EMAIL = "aatikturk@gmail.com" AUTHOR_EMAIL = "aatikturk@gmail.com"
@ -18,7 +18,7 @@ LONG_DESCRIPTION = (HERE / "README.md").read_text()
LONG_DESC_TYPE = "text/markdown" LONG_DESC_TYPE = "text/markdown"
# Dependencies for the package # Dependencies for the package
INSTALL_REQUIRES = ["websocket-client"] INSTALL_REQUIRES = ["websocket-client", "tomli >= 1.1.0;python_version < '3.11'"]
# Development dependencies # Development dependencies
EXTRAS_REQUIRE = { EXTRAS_REQUIRE = {
@ -31,7 +31,7 @@ EXTRAS_REQUIRE = {
} }
# Python version requirement # Python version requirement
PYTHON_REQUIRES = ">=3.11" PYTHON_REQUIRES = ">=3.10"
setup( setup(
name=PACKAGE_NAME, name=PACKAGE_NAME,