Skip to content

requests.SetRecordDirectory takes 1 positional argument but 2 were given #88

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
REDS1736 opened this issue Jul 10, 2023 · 6 comments
Open

Comments

@REDS1736
Copy link

Executing requests.SetRecordDirectory('C:/Users/REDS1736/Desktop') results in the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: __init__() takes 1 positional argument but 2 were given

I already tried giving the desired path as a keyword (requests.SetRecordDirectory(recordDirectory='C:/Users/REDS1736/Desktop'); i guessed the name of the keyword using this official piece of OBS docs: https://github.com/obsproject/obs-websocket/blob/master/docs/generated/protocol.md#setrecorddirectory), but that just gives me a new error:

<SetRecordDirectory request ({'directory': 'C:/Users/REDS1736/Desktop/'}) called: failed ({})> 

I suppose, the keyword i use is wrong but i can't find the right one.

@RaphBarniques
Copy link

RaphBarniques commented Jul 12, 2023

Same here!

SetFilenameFormatting gets me a "takes 1 positional argument but 2 were given" and GetFilenameFormatting gets me a "request call failed"

Here is my code:

from obswebsocket import obsws, requests

client = obsws("localhost", 4455)
client.connect()
print(client.call(requests.GetFilenameFormatting()))
client.call(requests.SetFilenameFormatting("TESTNAME"))
print(client.call(requests.GetFilenameFormatting()))
client.call(requests.StartRecording())
client.disconnect()

Edit: Looking at the Requests Protocol sheet I managed to find the new way (v5) of formatting the request for the recording part (StartRecording -> StartRecord). Unfortunately I did not find the new way of manipulating the filename formatting. I will continue to search.

@methecooldude
Copy link

Also getting similar when using SetSceneItemRender (in legacy v4 mode)...
Baserequests.__init__() takes 1 positional argument but 3 were given

@iarspider
Copy link

With the new version of obs-websocket-py you need to explicitly name parameters, e.g.:

requests.SetFilenameFormatting(**{'filename-formatting': 'TESTNAME'})

(yes, you need to use dictionary unpacking, since the key contains -)
And looks like the V5 doesn't have a way to set filename formatting

@iarspider
Copy link

SetSceneItemRender

See keywords here: https://github.com/obsproject/obs-websocket/blob/4.x-compat/docs/generated/protocol.md#setsceneitemrender, and use the same dictionary unpacking trick.

@methecooldude
Copy link

SetSceneItemRender

See keywords here: https://github.com/obsproject/obs-websocket/blob/4.x-compat/docs/generated/protocol.md#setsceneitemrender, and use the same dictionary unpacking trick.

Ah, thanks. I did think a bit after commenting and some reading that it might be the parameter names... but didn't know about dictionary unpacking, so thanks for that :)

@iarspider
Copy link

@Elektordi would it be possible to restore the old behavior, when kwargs with _ were converted to dashed ones?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants