Elektordi / obs-websocket-py

Python library to communicate with an obs-websocket server (for OBS Studio)
MIT License
235 stars 59 forks source link

Problem adding new scene #94

Closed DavidCoq closed 3 months ago

DavidCoq commented 3 months ago

I have a problem with adding a new scene. When I run the code, the Python interpreter responds as follows:

Traceback (most recent call last): File "c:\obs_test.py", line 19, in <module> response = ws.call(requests.CreateScene(scene_name)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: Baserequests.__init__() takes 1 positional argument but 2 were given

What's causing the problem?

from obswebsocket import obsws, requests

# Configure OBS WebSocket connection details
host = "localhost"
port = 4455  # The port configured in OBS
password = "password"
# Create an instance of the connection
ws = obsws(host, port, password)
try:
    # Connect to the server
    ws.connect()

    # Name of the scene to create
    scene_name = "MyNewScene"

    # Create a new scene
    response = ws.call(requests.CreateScene(scene_name))

    # Check if the request was successful
    if response.status:
        print("Scene created successfully!")
    else:
        print("Error creating scene:", response.error)

finally:
    # Disconnect from the server
    ws.disconnect()
iarspider commented 3 months ago

Try this: response = ws.call(requests.CreateScene(sceneName=scene_name))

DavidCoq commented 3 months ago

I hadn't noticed that the solution was also written on the program release page. Thank you