julian-o / pyslobs Goto Github PK
View Code? Open in Web Editor NEWPython wrapper to the StreamLabs OBS API
License: MIT License
Python wrapper to the StreamLabs OBS API
License: MIT License
References should be updated.
Possible steps, in order of priority:
The later steps don't look like they will be worth the effort - happy to hear opinions.
Hi, fantastic work on this wrapper! I installed with pip and it threw error: No module named 'tests'
Just a small thing, thought you'd like to know.
This module will be very meaningful to me.
Thank you in advance.
I get an error with the following code.
File "D:\twitchbot\.venv\lib\site-packages\pyslobs\connection.py", line 104, in _authenticate
raise AuthenticationFailure("%s" % response)
pyslobs.connection.AuthenticationFailure: {'id': 'auth_request', 'jsonrpc': '2.0', 'error': {'code': -32603, 'message': 'INTERNAL_JSON_RPC_ERROR Invalid token'}}
What kind of authentication is this supposed to be failing?
I've also included the ini file.
{pyslobs.ini}
[connection]
domain=localhost
port=59650
token=QRcode's APITOKEN
Sorry for my poor English.
StreamLabs sometimes returns a Notification with a subtype of NEWS, despite this not being mentioned in the documentation (at time of writing).
Handle the new value of the subtype.
When ı run this code, output is just "Waiting for luamacros script...". Can you help me?
When I try to import SlobsConnection, I have an error with AudioService.
File "myscript.py", line 4, in <module>
from pyslobs import SlobsConnection
File "D:\Apps\Python\Python38-32\lib\site-packages\pyslobs\__init__.py", line 3, in <module>
from .slobs.audioservice import AudioService
File "D:\Apps\Python\Python38-32\lib\site-packages\pyslobs\slobs\audioservice.py", line 8, in <module>
class AudioService(SlobsService):
File "D:\Apps\Python\Python38-32\lib\site-packages\pyslobs\slobs\audioservice.py", line 18, in AudioService
async def get_sources(self) -> list[AudioSource]:
TypeError: 'type' object is not subscriptable
Else, thanks for work. :)
I get this error every once in a while. Is there something I can do to prevent it?
SceneItem has some "attributes" (Python properties) recording_visible
, stream_visible
and visible
. These are not used by PySlobs, but are local cache values to reduce the need for clients to have to refetch objects. (They can be out-of-date!)
SceneNode.set_settings()
modifies a the visibility of a scene_node, and correctly updates the local cache values. It is exercised in ex_scenenodes.py
.
SceneNode.set_visbility()
also modifies a the visibility of a scene_node. It does NOT updates the local cache values. It is NOT exercised.
It should have the line self._visible = visible
, and it should be exercised to show it works correctly.
Hi,
i was wondering if there is an option to set the visibility of sources in a scene. I animated a little overlay for a game, which should be visible when ingame and invisible when i'm in the main menu. I searched throught the sourcesservice.py and source.py files to find a method which does that, but i could not find anything. I also tried to set every "visible" option in the properties to false and then update the source properties with "set_properties_form_data", but that did'nt work either, the settings were updated but the overlay was still visible. Can you help me out with that?
Thanks
I'm sorry for asking personal questions again.
I'm thinking of getting someone else's API token to control it.
Is this technically possible?
If you could do that, what do you think you would need?
Thank you in advance!
ERROR:slobsapi.SlobsConnection:_receive_and_dispatch failing.
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/pyslobs/connection.py", line 209, in _receive_and_dispatch
message = await self._receive_message()
File "/usr/local/lib/python3.10/site-packages/pyslobs/connection.py", line 197, in _receive_message
return await loop.run_in_executor(None, self.websocket.receive_message)
File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/local/lib/python3.10/site-packages/pyslobs/connection.py", line 65, in receive_message
raw_message = self.socket.recv()
File "/usr/local/lib/python3.10/site-packages/websocket/_core.py", line 362, in recv
opcode, data = self.recv_data()
File "/usr/local/lib/python3.10/site-packages/websocket/_core.py", line 385, in recv_data
opcode, frame = self.recv_data_frame(control_frame)
File "/usr/local/lib/python3.10/site-packages/websocket/_core.py", line 406, in recv_data_frame
frame = self.recv_frame()
File "/usr/local/lib/python3.10/site-packages/websocket/_core.py", line 445, in recv_frame
return self.frame_buffer.recv_frame()
File "/usr/local/lib/python3.10/site-packages/websocket/_abnf.py", line 338, in recv_frame
self.recv_header()
File "/usr/local/lib/python3.10/site-packages/websocket/_abnf.py", line 294, in recv_header
header = self.recv_strict(2)
File "/usr/local/lib/python3.10/site-packages/websocket/abnf.py", line 373, in recv_strict
bytes = self.recv(min(16384, shortage))
File "/usr/local/lib/python3.10/site-packages/websocket/_core.py", line 529, in _recv
return recv(self.sock, bufsize)
File "/usr/local/lib/python3.10/site-packages/websocket/_socket.py", line 122, in recv
raise WebSocketConnectionClosedException(
websocket._exceptions.WebSocketConnectionClosedException: Connection to remote host was lost.
Error occurred: Connection to remote host was lost.
I found that I wanted to create a SlobsConnection
, launch a background thread to handle the background connection, and then close the connection.
Investigating this revealed several areas that could be improved:
close() can be changed from an co-routine to a regular method. This is a minor change to the API, but it is a breaking change. Looks like it is time for v2.0.0!
Clean-up should occur even if an unexpected exception is raised in receive_and_dispatch
If the background task terminates, the logging should always show why.
If the connection is already closed, calling methods on it should fail with ProtocolError
References to clean-up tasks are not being kept, leaving a risk that they would be garbage-collected before completion.
I apologize for raising this issue for very personal reasons...
My guess is to do get_scene to get the name of the scene and then create_source.
For now,I used list_all_scenes made by examples to get the name.
What should I do from here?
async def createing_sources(conn):
list_all_scenes(conn)
ss = SourcesService(conn)
scene = await ss.create_source()
??
Thank you in advance.
SlobsConnection._receive_and_dispatch
receives messages from StreamLabs Desktop, and assumes they have an id
field (as a response to a request) or a result
field, in response to a subscription.
While I was streaming, it got a response which did not contain either, causing a log message:
_receive_and_dispatch failing.
Traceback (most recent call last):
File "[omitted]\pyslobs\connection.py", line 192, in _receive_and_dispatch
key = message["result"]["resourceId"]
KeyError: 'result'
Whatever this message is, it should be handled.
Hey, i've noticed that the transform_postition of an Item is wrong.
instead of excpected something like:
IVec2(x=50, y=0) (with two integers, one as x and one as y)
it was:
IVec2(x='x', y='y')
Strings instead of the actual parameters in the tuple.
The problem is in the sceneitem_factory (factories.py line 33)
The faulty part is the else:
instead of this:
def sceneitem_factory(connection, json_dict):
# We see inconsistency in choices of API here.
if isinstance(json_dict["transform"]["position"], list):
transform_position = (
IVec2(
x=json_dict["transform"]["position"][0],
y=json_dict["transform"]["position"][1],
),
)
else:
transform_position = IVec2(*json_dict["transform"]["position"])
It should be that:
def sceneitem_factory(connection, json_dict):
# We see inconsistency in choices of API here.
if isinstance(json_dict["transform"]["position"], list):
transform_position = (
IVec2(
x=json_dict["transform"]["position"][0],
y=json_dict["transform"]["position"][1],
),
)
else:
transform_position = (
IVec2(
x=json_dict["transform"]["position"]['x'] ,
y=json_dict["transform"]["position"]['y'] ,
)
)
Should i create a PR for that?
Background:
The API has many references to "id" fields. id()
is a built-in function in Python, and PySLOBS avoids using it directly to avoid warnings that the built-in is being hidden.
Private fields in a record are consistently called _id
.
Method parameters are consistently called id_
.
The properties fields are inconsistent though: They are called id
in Scene
and Source
(and in test code), but they are called id_
in SceneNode
(and its subclasses).
Whichever decision is made, make the properties all consistent.
The first argument of both is not named "self".
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.