Exemplo n.º 1
0
async def main():

    async with OBSWS('localhost', 4444, "1234") as obsws:

        # We can send an empty StartStreaming request (in that case the plugin
        # will use OBS configuration), but let's provide some settings as well
        stream_settings = StreamSettings(
            server="rtmp://example.org/my_application",
            key="secret_stream_key",
            use_auth=False)
        stream = Stream(
            settings=stream_settings,
            type="rtmp_custom",
        )

        # Now let's actually perform a request
        response = await obsws.require(EnableStudioModeRequest())
        response = await obsws.require(GetVolumeRequest(source="a"))
        print(response)
        response = await obsws.require(
            SetCurrentSceneRequest(scene_name="On Arrive"))

        response = await obsws.require(ToggleMuteRequest(source="a"))
#         response = await obsws.require(StartStopRecordingRequest())

#         response = await obsws.require(StartRecordingRequest())
#         response = await obsws.require(StartStreamingRequest(stream=stream))
    print(response)
async def send_command(scene_name):
	"""
	Sends the change scene command to OBS
	"""

	async with OBSWS('localhost', 4444, secrets.obs_wss_pass) as obsws:

		response = await obsws.require(SetCurrentSceneRequest(scene_name=f"scene_{scene_name}"))
		if response.status == ResponseStatus.OK:
			print(f"OBS: Scene set to {scene_name}")
		else:
			print("error:", response.error)
Exemplo n.º 3
0
def main():
    obsws = OBSWS('localhost', 4444, "")

    for s in scenes:
        response =   obsws.require(SetCurrentSceneRequest(scene_name=s))

        # Check if everything is OK
        if response.status == ResponseStatus.OK:
            print("Scene set: ",s)
        else:
            print("Scene not set. Reason:", response.error)
            time.sleep(5)
Exemplo n.º 4
0
async def main():

    async with OBSWS('localhost', 4444, "") as obsws:

        for s in scenes:
            response = await obsws.require(SetCurrentSceneRequest(scene_name=s))

            # Check if everything is OK
            if response.status == ResponseStatus.OK:
                print("Scene set: ",s)
            else:
                print("Scene not set. Reason:", response.error)
            await asyncio.sleep(5)
Exemplo n.º 5
0
async def mainx(s):
    #global s

    async with OBSWS(obs_ip, obs_port, "") as obsws:

        response = await obsws.require(SetCurrentSceneRequest(scene_name=s))

        # Check if everything is OK
        if response.status == ResponseStatus.OK:
            res = "Scene set: " + s
            #print("Scene set: ",s)
        else:
            res = "Scene " + s + " not set. Reason:" + response.error
            #print("Scene ", s, " not set. Reason:", response.error)
        print(res)
        return (res)
Exemplo n.º 6
0
async def setscene(scene):

    async with OBSWS(obs_ip, obs_port, "") as obsws:

        response = await obsws.require(SetCurrentSceneRequest(scene_name=scene)
                                       )

        # Check if everything is OK
        if response.status == ResponseStatus.OK:
            result = "Scene set: " + scene
            status = "ok"
        else:
            result = "Scene " + scene + " not set. Reason:" + response.error
            status = "error"

        res = {"status": status, "result": result}

        return (res)
Exemplo n.º 7
0
async def main():
    async with OBSWS(args.host, args.port) as obsws:
        if args.scene:
            response = await obsws.require(
                SetCurrentSceneRequest(scene_name=args.scene))
            if args.silent:
                subprocess.Popen(
                    ["notify-send", "OBS Scene changed to " + args.scene],
                    shell=False,
                    stdout=subprocess.PIPE,
                    stderr=subprocess.DEVNULL)
                print("Scene changed to " + args.scene)
        if args.profile:
            response = await obsws.require(
                SetCurrentProfileRequest(profile_name=args.profile))
            if args.silent:
                subprocess.Popen(
                    ["notify-send", "OBS Profile changed to " + args.scene],
                    shell=False,
                    stdout=subprocess.PIPE,
                    stderr=subprocess.DEVNULL)
                print("Profile changed to " + args.scene)
Exemplo n.º 8
0
async def main():
    ports = find_board(get_serial_ports())
    board = arduino(ports[0])

    streaming = False
    startup = True
    board.release_latches()

    async with OBSWS('localhost', 4444, 'password') as obsws:

        if startup:
            board.flush()
            board.get_state()
            ret = board.read()
            if ret:
                cmd, state = ret

            board.off_air()
            await obsws.require(SetCurrentSceneRequest(
                {"scene-name": "NotLive"}))
            await obsws.require(StopStreamingRequest())
            streaming = False
            state[board_status.stream_button] = 0
            startup = False

        obs_status = await obsws.require(GetStreamingStatusRequest())  #NOQA
        streaming = obs_status['streaming']

        while True:
            try:
                obs_status = await obsws.require(GetStreamingStatusRequest())  #NOQA
                if obs_status is not None:
                    streaming = obs_status['streaming']

                board.flush()
                board.get_state()
                ret = board.read()

                if ret:
                    cmd, state = ret
                    # print("{}  :  {}".format(ret, streaming))
                    # logger.info(cmd)
                    # logger.info(state)
                    if state[board_status.stream_button] == 1 \
                            and streaming is False:
                        board.on_air()
                        await obsws.require(SetCurrentSceneRequest(
                            {"scene-name": "Live"}))
                        await obsws.require(StartStreamingRequest())
                        streaming = True
                        state[board_status.stream_button] = 0

                    elif state[board_status.stream_button] == 1 \
                            and streaming is True:
                        board.off_air()
                        await obsws.require(SetCurrentSceneRequest(
                            {"scene-name": "NotLive"}))
                        await obsws.require(StopStreamingRequest())
                        streaming = False
                        state[board_status.stream_button] = 0

                    elif state[board_status.player_timeout] == 0 \
                            and streaming is True:
                        board.off_air()
                        await obsws.require(SetCurrentSceneRequest(
                            {"scene-name": "NotLive"}))
                        await obsws.require(StopStreamingRequest())
                        streaming = False
                        state[board_status.stream_button] = 0

                board.release_latches()

            except ValueError:
                print("sleeping a bit, yawn")
                time.sleep(2)