20 Commits

Author SHA1 Message Date
4e9fb934be fix payload key 2025-07-05 15:42:40 +01:00
82baa40e79 reqclient rework initial commit
position arguments removed.

keyword-only argument enforced.

type annotations added

this is a breaking change and would required a major version bump.
2025-06-28 14:24:50 +01:00
3bce50701e add v5.4, v5.5 methods
v5.4:
- get_source_filter_kind_list
- get_scene_item_source

v5.5:
- split_record_file
- create_record_chapter

minor bump
2025-06-23 06:25:31 +01:00
8e8062d5c8 Merge pull request #57 from onyx-and-iris/dev
Return response class for toggle_record
2025-05-14 20:19:49 +01:00
6f64e884d8 md fix 2025-05-07 22:00:19 +01:00
90abc4f9ee upd test_get_hot_key_list
- check hotkey list is not empty
- check it has at least one OBSBasic. hotkey.
2025-05-07 19:13:09 +01:00
f564f53c69 return response class for toggle_record()
patch bump
2025-05-07 18:42:29 +01:00
4d9dfa9d11 Merge pull request #55 from onyx-and-iris/dev
Update tests
2025-02-11 14:19:27 +00:00
9e361f0f8a fix hatch link 2025-02-11 10:16:56 +00:00
797161a6f2 import Callable, Iterable from collections.abs instead of typing.
update tests to reflect changes in the API.

reorganise hatch envs

add black,isort configs to pyproject.toml

add pre-commit config
2025-02-11 09:51:00 +00:00
0fe78197fc Merge branch 'aatikturk:main' into dev 2025-02-10 12:27:07 +00:00
Adem
9c4c5a1df9 Merge pull request #53 from Zynthasius39/dev-zynt
Fix Trigger Hotkey Methods
2025-02-10 15:02:36 +03:00
f52ac163b8 patch bump version 2025-02-10 09:12:09 +00:00
Zynthasius39
197a60a7cd Fix trigger_hot_key_by_key_sequence() method 2025-02-08 18:31:12 +04:00
Zynthasius39
633093ead4 Fix trigger_hot_key_by_name() method 2025-02-08 17:59:45 +04:00
935392a0b6 Merge branch 'aatikturk:main' into dev 2025-01-25 22:34:36 +00:00
d2f2926334 Merge pull request #51 from marzeq/patch-1
Fix project.license field in pyproject.toml so that setup.py doesn't fail
2025-01-25 21:48:55 +00:00
marzeq
58cd50dd6c Fix project.license field in pyproject.toml so that setup.py doesn't fail 2025-01-25 21:34:27 +01:00
7614cdfe4a add py12 to test matrix 2024-02-21 14:15:40 +00:00
Adem
9402f2e472 Merge pull request #43 from onyx-and-iris/fix-disconnect
Add disconnect() methods. Default ws timeout to None for event thread.
2024-01-21 15:45:06 +03:00
11 changed files with 1369 additions and 736 deletions

2
.gitignore vendored
View File

@@ -51,7 +51,7 @@ venv.bak/
.python-version
# Test/config
quick.py
test-*.py
config.toml
obsws.log

10
.pre-commit-config.yaml Normal file
View File

@@ -0,0 +1,10 @@
repos:
- repo: local
hooks:
- id: format
name: format
entry: hatch run style:fmt
language: system
pass_filenames: false
verbose: true
files: \.(py)$

View File

@@ -1,5 +1,6 @@
[![PyPI version](https://badge.fury.io/py/obsws-python.svg)](https://badge.fury.io/py/obsws-python)
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://github.com/aatikturk/obsstudio_sdk/blob/main/LICENSE)
[![Hatch project](https://img.shields.io/badge/%F0%9F%A5%9A-Hatch-4051b5.svg)](https://github.com/pypa/hatch)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)
@@ -92,7 +93,7 @@ resp = cl_req.send("GetVersion", raw=True)
print(f"response data: {resp}")
```
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][obsws-reqs]
### Events
@@ -125,7 +126,7 @@ 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](https://github.com/obsproject/obs-websocket/blob/master/docs/generated/protocol.md#events)
For a full list of events refer to [Events][obsws-events]
### Attributes
@@ -149,7 +150,7 @@ def on_scene_created(data):
- The following attributes are available:
- `req_name`: name of the request.
- `code`: request 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)
- For a full list of status codes refer to [Codes][obsws-codes]
### Logging
@@ -168,18 +169,21 @@ logging.basicConfig(level=logging.DEBUG)
### Tests
First install development dependencies:
`pip install -e .['dev']`
To run all tests:
Install [hatch][hatch-install] and then:
```
pytest -v
hatch test
```
### 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)
- [OBS Websocket SDK][obsws-pro]
[obsws-reqs]: https://github.com/obsproject/obs-websocket/blob/master/docs/generated/protocol.md#requests
[obsws-events]: https://github.com/obsproject/obs-websocket/blob/master/docs/generated/protocol.md#events
[obsws-codes]: https://github.com/obsproject/obs-websocket/blob/master/docs/generated/protocol.md#requeststatus
[obsws-pro]: https://github.com/obsproject/obs-websocket/blob/master/docs/generated/protocol.md#obs-websocket-501-protocol
[hatch-install]: https://hatch.pypa.io/latest/install/

View File

@@ -96,10 +96,8 @@ class ObsClient:
auth = base64.b64encode(
hashlib.sha256(
(
secret
+ self.server_hello["d"]["authentication"]["challenge"].encode()
)
secret
+ self.server_hello["d"]["authentication"]["challenge"].encode()
).digest()
).decode()

View File

@@ -1,4 +1,5 @@
from typing import Callable, Iterable, Union
from collections.abc import Callable, Iterable
from typing import Union
from .util import as_dataclass, to_camel_case, to_snake_case

File diff suppressed because it is too large Load Diff

View File

@@ -1 +1 @@
version = "1.7.0"
version = "1.8.0"

View File

@@ -7,7 +7,7 @@ name = "obsws-python"
dynamic = ["version"]
description = "A Python SDK for OBS Studio WebSocket v5.0"
readme = "README.md"
license = "GPL-3.0-only"
license = { text = "GPL-3.0-only" }
requires-python = ">=3.9"
authors = [
{ name = "Adem Atikturk", email = "aatikturk@gmail.com" },
@@ -17,14 +17,6 @@ dependencies = [
"websocket-client",
]
[project.optional-dependencies]
dev = [
"black",
"isort",
"pytest",
"pytest-randomly",
]
[project.urls]
Homepage = "https://github.com/aatikturk/obsws-python"
@@ -36,19 +28,58 @@ include = [
"/obsws_python",
]
[tool.hatch.envs.default]
dependencies = ["pre-commit"]
[tool.hatch.envs.e]
dependencies = ["keyboard"]
[tool.hatch.envs.e.scripts]
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]
[tool.hatch.envs.hatch-test]
randomize = true
[tool.hatch.envs.hatch-test.scripts]
run = "pytest{env:HATCH_TEST_ARGS:} {args}"
[[tool.hatch.envs.hatch-test.matrix]]
python = ["313", "312", "311", "310", "39"]
[tool.hatch.envs.style]
detached = true
dependencies = [
"pytest",
"black",
"isort",
]
[tool.hatch.envs.test.scripts]
run = 'pytest -v'
[tool.hatch.envs.style.scripts]
check = [
"black --check --diff .",
"isort --check-only --diff .",
]
fmt = [
"isort .",
"black .",
]
[[tool.hatch.envs.test.matrix]]
python = ["39", "310", "311"]
[tool.black]
line-length = 88
include = '\.pyi?$'
# 'extend-exclude' excludes files or directories in addition to the defaults
extend-exclude = '''
(
^/\.git/ # exclude all files in the .git directory
^/\.hatch/ # exclude all files in the .hatch directory
^/\.pytest_cache/ # exclude all files in the .pytest_cache directory
| .*_pb2.py # exclude autogenerated Protocol Buffer files anywhere in the project
)
'''
[tool.isort]
profile = "black"
skip = [".gitignore", ".dockerignore"]
skip_glob = [".git/*", ".hatch/*", ".pytest_cache/*"]

View File

@@ -18,7 +18,12 @@ class TestAttrs:
def test_get_current_program_scene_attrs(self):
resp = req_cl.get_current_program_scene()
assert resp.attrs() == ["current_program_scene_name"]
assert resp.attrs() == [
"current_program_scene_name",
"current_program_scene_uuid",
"scene_name",
"scene_uuid",
]
def test_get_transition_kind_list_attrs(self):
resp = req_cl.get_transition_kind_list()

View File

@@ -1,4 +1,5 @@
import pytest
from obsws_python.callback import Callback

View File

@@ -13,35 +13,8 @@ class TestRequests:
def test_get_hot_key_list(self):
resp = req_cl.get_hot_key_list()
obsbasic_hotkey_list = [
"OBSBasic.SelectScene",
"OBSBasic.QuickTransition.1",
"OBSBasic.QuickTransition.2",
"OBSBasic.QuickTransition.3",
"OBSBasic.StartStreaming",
"OBSBasic.StopStreaming",
"OBSBasic.ForceStopStreaming",
"OBSBasic.StartRecording",
"OBSBasic.StopRecording",
"OBSBasic.PauseRecording",
"OBSBasic.UnpauseRecording",
"OBSBasic.SplitFile",
"OBSBasic.StartReplayBuffer",
"OBSBasic.StopReplayBuffer",
"OBSBasic.StartVirtualCam",
"OBSBasic.StopVirtualCam",
"OBSBasic.EnablePreview",
"OBSBasic.DisablePreview",
"OBSBasic.EnablePreviewProgram",
"OBSBasic.DisablePreviewProgram",
"OBSBasic.ShowContextBar",
"OBSBasic.HideContextBar",
"OBSBasic.Transition",
"OBSBasic.ResetStats",
"OBSBasic.Screenshot",
"OBSBasic.SelectedSourceScreenshot",
]
assert all(x in resp.hotkeys for x in obsbasic_hotkey_list)
assert resp.hotkeys
assert any(x.startswith("OBSBasic.") for x in resp.hotkeys)
@pytest.mark.parametrize(
"name,data",
@@ -55,6 +28,7 @@ class TestRequests:
resp = req_cl.get_persistent_data("OBS_WEBSOCKET_DATA_REALM_PROFILE", name)
assert resp.slot_value == data
@pytest.mark.skip(reason="possible bug in obs-websocket, needs checking")
def test_profile_list(self):
req_cl.create_profile("test")
resp = req_cl.get_profile_list()
@@ -97,11 +71,15 @@ class TestRequests:
"START_TEST", "test", "color_source_v3", {"color": 4294945535}, True
)
resp = req_cl.get_input_list()
assert {
"inputKind": "color_source_v3",
"inputName": "test",
"unversionedInputKind": "color_source",
} in resp.inputs
for input_item in resp.inputs:
if input_item["inputName"] == "test":
assert input_item["inputKind"] == "color_source_v3"
assert input_item["unversionedInputKind"] == "color_source"
break
else:
# This else block is executed if the for loop completes without finding the input_item with inputName "test"
raise AssertionError("Input with inputName 'test' not found")
resp = req_cl.get_input_settings("test")
assert resp.input_kind == "color_source_v3"
assert resp.input_settings == {"color": 4294945535}