Skip to main content

Python library to communicate with an obs-websocket server.

Project description

Python3 library to communicate with an obs-websocket server.

Licensed under the MIT License

Project pages

GitHub project: https://github.com/Elektordi/obs-websocket-py

PyPI package: https://pypi.org/project/obs-websocket-py/

Installation

Just run pip3 install obs-websocket-py in your Python venv or directly on your system.

For manual install, git clone the github repo and copy the directory obswebsocket in your python project root.

Requires: websocket-client (from pip)

Usage

See python scripts in the samples directory.

Or take a look at the documentation below:

Output of ``pydoc obswebsocket.core.obsws``:

Help on class obsws in obswebsocket.core:

obswebsocket.core.obsws = class obsws
 |  Core class for using obs-websocket-py
 |
 |  Simple usage: (v5 api)
 |      >>> from obswebsocket import obsws, requests
 |      >>> client = obsws("localhost", 4455, "secret")
 |      >>> client.connect()
 |      >>> client.call(requests.GetVersion()).getObsVersion()
 |      '29.0.0'
 |      >>> client.disconnect()
 |
 |  Legacy usage: (v4 api)
 |      >>> from obswebsocket import obsws, requests
 |      >>> client = obsws("localhost", 4444, "secret", legacy=True)
 |      >>> client.connect()
 |      >>> client.call(requests.GetVersion()).getObsStudioVersion()
 |      '25.0.0'
 |      >>> client.disconnect()
 |
 |  For advanced usage, including events callback, see the 'samples' directory.
 |
 |  Methods defined here:
 |
 |  __init__(self, host='localhost', port=4444, password='', legacy=None, timeout=60, authreconnect=0, on_connect=None, on_disconnect=None)
 |      Construct a new obsws wrapper
 |
 |      :param host: Hostname to connect to
 |      :param port: TCP Port to connect to (Default is 4444)
 |      :param password: Password for the websocket server (Leave this field empty if auth is not enabled)
 |      :param legacy: Server is using old obs-websocket protocol (v4). Default is v5 (False) except if port is 4444.
 |      :param timeout: How much seconds to wait for an answer after sending a request.
 |      :param authreconnect: Try to reconnect if websocket is closed, value is number of seconds between attemps.
 |      :param on_connect: Function to call after successful connect, with parameter (obsws)
 |      :param on_disconnect: Function to call after successful disconnect, with parameter (obsws)
 |
 |  call(self, obj)
 |      Make a call to the OBS server through the Websocket.
 |
 |      :param obj: Request (class from obswebsocket.requests module) to send
 |          to the server.
 |      :return: Request object populated with response data.
 |
 |  connect(self)
 |      Connect to the websocket server
 |
 |      :return: Nothing
 |
 |  disconnect(self)
 |      Disconnect from websocket server
 |
 |      :return: Nothing
 |
 |  reconnect(self)
 |      Restart the connection to the websocket server
 |
 |      :return: Nothing
 |
 |  register(self, func, event=None)
 |      Register a new hook in the websocket client
 |
 |      :param func: Callback function pointer for the hook
 |      :param event: Event (class from obswebsocket.events module) to trigger
 |          the hook on. Default is None, which means trigger on all events.
 |      :return: Nothing
 |
 |  unregister(self, func, event=None)
 |      Unregister a new hook in the websocket client
 |
 |      :param func: Callback function pointer for the hook
 |      :param event: Event (class from obswebsocket.events module) which
 |          triggered the hook on. Default is None, which means unregister this
 |          function for all events.
 |      :return: Nothing

Problems?

Please check on Github project issues, and if nobody else have experienced it before, you can file a new issue.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

obs-websocket-py-1.0.linux-x86_64.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

obs_websocket_py-1.0-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file obs-websocket-py-1.0.linux-x86_64.tar.gz.

File metadata

File hashes

Hashes for obs-websocket-py-1.0.linux-x86_64.tar.gz
Algorithm Hash digest
SHA256 b3f10780cc15e116c1793b4c20614c5e7cd361c7991f3670497306f0ad660095
MD5 a8a87b23eba69fb7d441b8d23a05b9ba
BLAKE2b-256 d0eca30bcdd9dbc629d418d045f7bef1b49330b2608797daa293dd84ce9342f3

See more details on using hashes here.

File details

Details for the file obs_websocket_py-1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for obs_websocket_py-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c563a57a551d3c07428fa066b5b3e6e5963f634fb0f54408a9b46ff5b7441d65
MD5 c4f79cdd38f6e379ad414907923970ca
BLAKE2b-256 79799d97d956d4ec2bf621770363bf5de02bf404abfe674be0cf4630f4b80878

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page