Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Not all endpoints in the official documentation are implemented.
pip install obsws-python
By default the clients connect with parameters:
host
: "localhost"port
: 4455password
: ""timeout
: NoneYou may override these parameters by storing them in a toml config file or passing them as keyword arguments.
Order of precedence: keyword arguments then config file then default values.
config file
A valid config.toml
might look like this:
[connection]
host = "localhost"
port = 4455
password = "mystrongpass"
It should be placed in your user home directory.
Example __main__.py
:
import obsws_python as obs
# pass conn info if not in config.toml
cl = obs.ReqClient(host='localhost', port=4455, password='mystrongpass', timeout=3)
# Toggle the mute state of your Mic input
cl.toggle_input_mute('Mic/Aux')
Method names for requests match the API calls but snake cased. If a successful call is made with the Request client and the response is expected to contain fields then a response object will be returned. You may then access the response fields as class attributes. They will be snake cased.
example:
# load conn info from config.toml
cl = obs.ReqClient()
# GetVersion, returns a response object
resp = cl.get_version()
# Access it's field as an attribute
print(f"OBS Version: {resp.obs_version}")
# SetCurrentProgramScene
cl.set_current_program_scene("BRB")
send(param, data=None, raw=False)
If you prefer to work with the JSON data directly the {ReqClient}.send() method accepts an argument, raw
. If set to True the raw response data will be returned, instead of a response object.
example:
resp = cl_req.send("GetVersion", raw=True)
print(f"response data: {resp}")
For a full list of requests refer to Requests
When registering a callback function use the name of the expected API event in snake case form, prepended with "on_".
example:
# load conn info from config.toml
cl = obs.EventClient()
def on_scene_created(data):
...
# SceneCreated
cl.callback.register(on_scene_created)
def on_input_mute_state_changed(data):
...
# InputMuteStateChanged
cl.callback.register(on_input_mute_state_changed)
# returns a list of currently registered events
print(cl.callback.get())
# You may also deregister a callback
cl.callback.deregister(on_input_mute_state_changed)
register(fns)
and deregister(fns)
accept both single functions and lists of functions.
For a full list of events refer to Events
For both request responses and event data you may inspect the available attributes using attrs()
.
example:
resp = cl.get_version()
print(resp.attrs())
def on_scene_created(data):
print(data.attrs())
OBSSDKError
: Base error class.OBSSDKTimeoutError
: Raised if a timeout occurs during sending/receiving a request or receiving an eventOBSSDKRequestError
: Raised when a request returns an error code.
req_name
: name of the request.code
: request status code.If you want to see the raw messages simply set log level to DEBUG
example:
import obsws_python as obs
import logging
logging.basicConfig(level=logging.DEBUG)
...
First install development dependencies:
pip install -e .['dev']
To run all tests:
pytest -v
For the full documentation:
FAQs
A Python SDK for OBS Studio WebSocket v5.0
We found that obsws-python demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.