Compare commits

...

2 Commits

Author SHA1 Message Date
Alex Orid
5d9831fc30 minor fixes 2021-05-04 16:54:45 -04:00
Alex Orid
e05183ffeb Working Version 2021-05-04 16:23:00 -04:00
4 changed files with 105 additions and 16 deletions

View File

@ -31,7 +31,7 @@ class Command_lights_v2(AbstractCommand, metaclass=ABCMeta):
praxis_logger_obj.log("\n Command>: " + command + rest)
isTwitch = False
if "Twitch" in source:
if "Twitch_ZZZ" in source: #temp changed for steam change back later
for name in config.allowedCommandsList_TwitchPowerUsers:
print(name)
tempName = user.lower()

72
obsWebSocket.py Normal file
View File

@ -0,0 +1,72 @@
import asyncio
import simpleobsws
import json
loop = asyncio.get_event_loop()
ws = simpleobsws.obsws(host='127.0.0.1', port=4444, password='MYSecurePassword', loop=loop) # Every possible argument has been passed, but none are required. See lib code for defaults.
async def default_request():
await ws.connect() # Make the connection to OBS-Websocket
result = await ws.call('GetVersion') # We get the current OBS version. More request data is not required
print(result) # Print the raw json output of the GetVersion request
await asyncio.sleep(1)
print("\n\n")
requests = result['available-requests'].split(',')
for r in requests:
print(r)
print("\n\n")
#data = {'source':'test_source', 'volume':0.5}
#result = await ws.call('SetVolume', data) # Make a request with the given data
#print(result)
await ws.disconnect() # Clean things up by disconnecting. Only really required in a few specific situations, but good practice if you are done making requests or listening to events.
async def make_custom_request(request, data=None):
await ws.connect() # Make the connection to OBS-Websocket
result = await ws.call(request) # We get the current OBS version. More request data is not required
print(result) # Print the raw json output of the GetVersion request
await asyncio.sleep(1)
if not data==None:
data = {'source':'test_source', 'volume':0.5}
result = await ws.call('SetVolume', data) # Make a request with the given data
print(result)
await ws.disconnect() # Clean things up by disconnecting. Only really required in a few specific situations, but good practice if you are done making requests or listening to events.
async def on_event(data):
print('New event! Type: {} | Raw Data: {}'.format(data['update-type'], data)) # Print the event data. Note that `update-type` is also provided in the data
async def on_switchscenes(data):
print("\n===========================================\n\n")
print('Scene switched to "{}". It has these sources: {}'.format(data['scene-name'], data['sources']))
def getRequests():
loop.run_until_complete(default_request())
def makeRequest(request):
loop.run_until_complete(make_custom_request(request))
def listenForData():
print("\n\nListener:")
loop = asyncio.get_event_loop()
ws = simpleobsws.obsws(host='127.0.0.1', port=4444, password='MYSecurePassword', loop=loop) # Every possible argument has been passed, but none are required. See lib code for defaults.
loop.run_until_complete(ws.connect())
ws.register(on_event) # By not specifying an event to listen to, all events are sent to this callback.
ws.register(on_switchscenes, 'SwitchScenes')
loop.run_forever()
if __name__ == "__main__":
#print("\n\nRequests:")
#loop.run_until_complete(get_requests())
#makeRequest("ToggleStudioMode")
#listenForData()
pass

View File

@ -1,17 +1,34 @@
import asyncio
import simpleobsws
import flask
from flask import request
loop = asyncio.get_event_loop()
ws = simpleobsws.obsws(host='127.0.0.1', port=4444, password='MYSecurePassword', loop=loop) # Every possible argument has been passed, but none are required. See lib code for defaults.
import obsWebSocket
async def make_request():
await ws.connect() # Make the connection to OBS-Websocket
result = await ws.call('GetVersion') # We get the current OBS version. More request data is not required
print(result) # Print the raw json output of the GetVersion request
await asyncio.sleep(1)
data = {'source':'test_source', 'volume':0.5}
result = await ws.call('SetVolume', data) # Make a request with the given data
print(result)
await ws.disconnect() # Clean things up by disconnecting. Only really required in a few specific situations, but good practice if you are done making requests or listening to events.
import os
import praxis_logging
praxis_logger_obj = praxis_logging.praxis_logger()
praxis_logger_obj.init(os.path.basename(__file__))
praxis_logger_obj.log("\n -Starting Logs: " + os.path.basename(__file__))
loop.run_until_complete(make_request())
api = flask.Flask(__name__)
# enable/disable this to get web pages of crashes returned
api.config["DEBUG"] = False
possibleRequests = []
def init():
#possibleRequests = obsWebSocket.getRequests()
#obsWebSocket.makeRequest("ToggleStudioMode")
obsWebSocket.listenForData()
@api.route('/api/v1/obs/websocket/getRequests', methods=['GET'])
def getRequests():
if 'name' in request.args:
pass
#if is_command(request.args['name']):
# return flask.make_response('', 200)
#else:
# return flask.make_response('', 404)
if __name__ == "__main__":
init()
api.run(host='0.0.0.0', port=6009)

View File

@ -28,7 +28,7 @@ def send_text(tts_sender, tts_text):
resp = requests.get(url)
if resp.status_code == 200:
print("Got the following message: %s" % resp.text)
data = loads(resp.text)
#data = loads(resp.text)
#msg = data['message']
#if msg is not None:
#pass