Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
S
SHMCamStudio
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
SexHackMe
SHMCamStudio
Commits
f5af9770
Commit
f5af9770
authored
6 months ago
by
nextime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add obs minimal support
parent
fa0cb6f4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
9 deletions
+61
-9
obs.py
shmcs/obs.py
+61
-9
No files found.
shmcs/obs.py
View file @
f5af9770
...
...
@@ -16,20 +16,70 @@
import
obsws_python
as
obs
import
time
def
on_scene_item_enable_state_changed
(
data
):
print
(
"scscene_item_enable_state_changed"
)
print
(
data
.
attrs
())
print
(
data
.
scene_item_enabled
,
data
.
scene_item_id
,
data
.
scene_name
,
data
.
scene_uuid
)
class
OBSControl
:
def
__init__
(
self
,
obs_server
,
config_section
):
self
.
online
=
False
self
.
last_try
=
time
.
time
()
-
11
self
.
lastping
=
time
.
time
()
-
20
self
.
server
=
obs_server
self
.
config_section
=
config_section
self
.
config_options
=
config
.
options
(
config_section
)
for
c
in
self
.
config_options
:
setattr
(
self
,
c
,
config
.
get
(
config_section
,
c
))
def
start
(
self
):
if
self
.
online
:
return
self
.
last_try
=
time
.
time
()
try
:
self
.
cl
=
obs
.
EventClient
(
host
=
self
.
host
,
port
=
self
.
port
,
password
=
self
.
password
)
self
.
cr
=
obs
.
ReqClient
(
host
=
self
.
host
,
port
=
self
.
port
,
password
=
self
.
password
)
self
.
cl
.
callback
.
register
(
self
.
on_scene_item_enable_state_changed
)
self
.
setonline
()
except
Exception
:
pass
def
setonline
(
self
):
self
.
online
=
True
def
setoffline
(
self
):
self
.
online
=
False
def
run_tasks
(
self
):
if
not
self
.
online
and
time
.
time
()
-
self
.
last_try
>
10
:
print
(
"OBS "
,
self
.
server
,
"starting... "
)
self
.
start
()
if
self
.
online
:
if
time
.
time
()
-
self
.
lastping
>
20
:
try
:
self
.
cr
.
broadcast_custom_event
({
'eventData'
:
{
'eventType'
:
'Ping'
,
'time'
:
time
.
time
()}})
self
.
lastping
=
time
.
time
()
except
:
self
.
setoffline
()
def
on_scene_item_enable_state_changed
(
self
,
data
):
print
(
"scscene_item_enable_state_changed"
)
print
(
data
.
attrs
())
print
(
data
.
scene_item_enabled
,
data
.
scene_item_id
,
data
.
scene_name
,
data
.
scene_uuid
)
def
run_obs_controller
():
cl
=
obs
.
EventClient
(
host
=
'192.168.42.115'
,
port
=
4455
,
password
=
'motorol4'
)
cr
=
obs
.
ReqClient
(
host
=
'192.168.42.115'
,
port
=
4455
,
password
=
'motorol4'
)
obs_servers
=
{}
for
k
in
[
x
for
x
in
config
.
sections
()
if
'OBS:'
in
x
]:
if
not
config
.
get
(
k
,
'active'
,
fallback
=
False
):
obs_servers
[
k
.
split
(
":"
,
1
)[
1
]]
=
OBSControl
(
k
.
split
(
":"
,
1
)[
1
],
k
)
#cl = obs.EventClient(host='192.168.42.115', port=4455, password='motorol4')
#cr = obs.ReqClient(host='192.168.42.115', port=4455, password='motorol4')
cl
.
callback
.
register
(
on_scene_item_enable_state_changed
)
#
cl.callback.register(on_scene_item_enable_state_changed)
print
(
cl
.
callback
.
get
())
#
print(cl.callback.get())
#cl.callback.deregister(on_input_mute_state_changed)
...
...
@@ -37,6 +87,8 @@ def run_obs_controller():
while
True
:
if
(
time
.
time
()
-
now
)
>
30
:
now
=
time
.
time
()
cr
.
broadcast_custom_event
({
'eventData'
:
{
'eventType'
:
'Ping'
,
'time'
:
time
.
time
()}})
#cr.broadcast_custom_event({'eventData': {'eventType': 'Ping', 'time': time.time()}})
for
o
in
obs_servers
.
keys
():
obs_servers
[
o
]
.
run_tasks
()
time
.
sleep
(
.01
)
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment