mirror of
https://github.com/onyx-and-iris/obsws-python.git
synced 2026-04-18 05:53:32 +00:00
More request tests added.
development dependencies added to setup.py fix error in __init__ kind parameter for get_input_list in reqclient now optional. request tests create/destroy test scenes on setup/teardown. license, isort, black badges added to readme.
This commit is contained in:
87
README.md
87
README.md
@@ -1,3 +1,7 @@
|
||||
[](https://github.com/aatikturk/obsstudio_sdk/blob/main/LICENSE)
|
||||
[](https://github.com/psf/black)
|
||||
[](https://pycqa.github.io/isort/)
|
||||
|
||||
# A Python SDK for OBS Studio WebSocket v5.0
|
||||
|
||||
This is a wrapper around OBS Websocket.
|
||||
@@ -36,7 +40,7 @@ Import and start using, keyword arguments are as follows:
|
||||
- `port`: port to access server
|
||||
- `password`: obs websocket server password
|
||||
|
||||
Example `__main__.py`
|
||||
Example `__main__.py`:
|
||||
|
||||
```python
|
||||
import obsstudio_sdk as obs
|
||||
@@ -48,6 +52,87 @@ cl = obs.ReqClient(host='localhost', port=4455, password='mystrongpass')
|
||||
cl.toggle_input_mute('Mic/Aux')
|
||||
```
|
||||
|
||||
### Requests
|
||||
|
||||
Method names for requests match the API calls but snake cased.
|
||||
|
||||
example:
|
||||
|
||||
```python
|
||||
cl = ReqClient()
|
||||
|
||||
# GetVersion
|
||||
resp = cl.get_version()
|
||||
|
||||
# SetCurrentProgramScene
|
||||
cl.set_current_program_scene()
|
||||
```
|
||||
|
||||
For a full list of requests refer to [Requests](https://github.com/obsproject/obs-websocket/blob/master/docs/generated/protocol.md#requests)
|
||||
|
||||
### Events
|
||||
|
||||
When registering a function callback use the name of the expected API event in snake case form.
|
||||
|
||||
example:
|
||||
|
||||
```python
|
||||
cl = EventClient()
|
||||
|
||||
def scene_created(data):
|
||||
...
|
||||
|
||||
# SceneCreated
|
||||
cl.callback.register(scene_created)
|
||||
|
||||
def input_mute_state_changed(data):
|
||||
...
|
||||
|
||||
# InputMuteStateChanged
|
||||
cl.callback.register(input_mute_state_changed)
|
||||
|
||||
# returns a list of currently registered events
|
||||
print(cl.callback.get())
|
||||
```
|
||||
|
||||
cl.callback accepts both a single or list of functions.
|
||||
|
||||
For a full list of events refer to [Events](https://github.com/obsproject/obs-websocket/blob/master/docs/generated/protocol.md#events)
|
||||
|
||||
### Attributes
|
||||
|
||||
For both request responses and event data you may inspect the available attributes using `attrs()`.
|
||||
|
||||
example:
|
||||
|
||||
```python
|
||||
resp = cl.get_version()
|
||||
print(resp.attrs())
|
||||
|
||||
def scene_created(data):
|
||||
print(data.attrs())
|
||||
```
|
||||
|
||||
### Errors
|
||||
|
||||
If a request fails an `OBSSDKError` will be raised with a status code.
|
||||
|
||||
For a full list of status codes refer to [Codes](https://github.com/obsproject/obs-websocket/blob/master/docs/generated/protocol.md#requeststatus)
|
||||
|
||||
### Tests
|
||||
|
||||
First install development dependencies:
|
||||
|
||||
`pip install -e .['dev']`
|
||||
|
||||
To run all tests:
|
||||
|
||||
```
|
||||
pytest -v
|
||||
```
|
||||
|
||||
### Official Documentation
|
||||
|
||||
For the full documentation:
|
||||
|
||||
- [OBS Websocket SDK](https://github.com/obsproject/obs-websocket/blob/master/docs/generated/protocol.md#obs-websocket-501-protocol)
|
||||
|
||||
Reference in New Issue
Block a user