From 7b13813090c57ab96859282be2313df68f6bbc5b Mon Sep 17 00:00:00 2001 From: wdpk Date: Sat, 20 Feb 2021 03:33:48 -1000 Subject: [PATCH 1/4] Added set volume feature Added $OBSsetVolume set volume for given source, 1-100 --- OBSRemoteParameters_StreamlabsParameter.py | 293 +++++++++++---------- 1 file changed, 161 insertions(+), 132 deletions(-) diff --git a/OBSRemoteParameters_StreamlabsParameter.py b/OBSRemoteParameters_StreamlabsParameter.py index 6b3f13e..84b994c 100644 --- a/OBSRemoteParameters_StreamlabsParameter.py +++ b/OBSRemoteParameters_StreamlabsParameter.py @@ -7,16 +7,18 @@ Version - 1.3.0 - $OBStimedSource now has an onoff or offon mode and $OBSscene now can accept an optional delay. - All parameters now use threading in Python to execute actions. - 1.2.0 - Added $OBStimedScene swap to a given scene for a set period of time, then swap to another given scene. - Changed script name to _StreamlabsSystem to accomedate the change in the bot name. - 1.1.0 - Added $OBStimedSource enabled a given source for a set period of time - 1.0.0 - Initial release containing $OBSsource, $OBSscene and $OBSstop + 1.4.0 + Added $OBSsetVolume set volume for given source, 1-100 + 1.3.0 + $OBStimedSource now has an onoff or offon mode and $OBSscene now can accept an optional delay. + All parameters now use threading in Python to execute actions. + 1.2.0 + Added $OBStimedScene swap to a given scene for a set period of time, then swap to another given scene. + Changed script name to _StreamlabsParameter to accomedate the change in the bot name. + 1.1.0 + Added $OBStimedSource enabled a given source for a set period of time + 1.0.0 + Initial release containing $OBSsource, $OBSscene and $OBSstop """ @@ -39,7 +41,7 @@ Website = "http://www.twitch.tv/ocgineer" Description = "Parameter Library to control OBS Studio with the regular command system." Creator = "Ocgineer" -Version = "1.3.0" +Version = "1.4.0" #--------------------------------------- # Global Vars @@ -49,173 +51,200 @@ RegObsSource = None RegObsTmdSrc = None RegObsTmdScn = None +RegObsAudioVolume = None #--------------------------------------- # Functions #--------------------------------------- def OpenReadMe(): - """ Open the script readme file in users default .txt application. """ - os.startfile(ReadMeFile) - return + """ Open the script readme file in users default .txt application. """ + os.startfile(ReadMeFile) + return def CallbackLogger(response): - """ Logs callback error response in scripts logger. """ - parsedresponse = json.loads(response) - if parsedresponse["status"] == "error": - Parent.Log("OBS Remote", parsedresponse["error"]) - return + """ Logs callback error response in scripts logger. """ + parsedresponse = json.loads(response) + if parsedresponse["status"] == "error": + Parent.Log("OBS Remote", parsedresponse["error"]) + return def ChangeToScene(scene, delay=None): - """ Swaps to a given scene, optionally after given amount of seconds. """ - if delay: - time.sleep(delay) - Parent.SetOBSCurrentScene(scene, CallbackLogger) - return + """ Swaps to a given scene, optionally after given amount of seconds. """ + if delay: + time.sleep(delay) + Parent.SetOBSCurrentScene(scene, CallbackLogger) + return def SetSourceVisibility(source, enabled, scene=None): - """ Set the targeted source visibility optionally in a scene. """ - Parent.SetOBSSourceRender(source, enabled, scene, CallbackLogger) - return + """ Set the targeted source visibility optionally in a scene. """ + Parent.SetOBSSourceRender(source, enabled, scene, CallbackLogger) + return def ChangeScenesTimed(scene_one, scene_two, delay): - """ Swap to one scene then to another scene after a set delay. """ - Parent.SetOBSCurrentScene(scene_one, CallbackLogger) - if delay: - time.sleep(delay) - Parent.SetOBSCurrentScene(scene_two, CallbackLogger) - return + """ Swap to one scene then to another scene after a set delay. """ + Parent.SetOBSCurrentScene(scene_one, CallbackLogger) + if delay: + time.sleep(delay) + Parent.SetOBSCurrentScene(scene_two, CallbackLogger) + return + +def SetAudioSourceVolume(source, volume): + """ Set the targeted source to the volume """ + #clip numbers at 100 + output = 100 if (int(volume) > 100) else volume + #Volume function expects value between 0-1, divide by 100 for convenience of using whole numbers in chat commands + Parent.SetOBSVolume(source, float(output)/100, CallbackLogger) + return def VisibilitySourceTimed(source, mode, delay, scene): - """ Disables a given source in optional scene after given amount of seconds. """ - # off - delay - off - if mode == "offon": - Parent.SetOBSSourceRender(source, False, scene, CallbackLogger) - if delay: - time.sleep(delay) - Parent.SetOBSSourceRender(source, True, scene, CallbackLogger) - # on - delay - off - else: - Parent.SetOBSSourceRender(source, True, scene, CallbackLogger) - if delay: - time.sleep(delay) - Parent.SetOBSSourceRender(source, False, scene, CallbackLogger) - # done - return + """ Disables a given source in optional scene after given amount of seconds. """ + # off - delay - off + if mode == "offon": + Parent.SetOBSSourceRender(source, False, scene, CallbackLogger) + if delay: + time.sleep(delay) + Parent.SetOBSSourceRender(source, True, scene, CallbackLogger) + # on - delay - off + else: + Parent.SetOBSSourceRender(source, True, scene, CallbackLogger) + if delay: + time.sleep(delay) + Parent.SetOBSSourceRender(source, False, scene, CallbackLogger) + # done + return #--------------------------------------- # Initialize data on load #--------------------------------------- def Init(): - """ Initialize Script. """ - - # Globals - global RegObsScene - global RegObsSource - global RegObsTmdSrc - global RegObsTmdScn - - # Compile regexes in init - RegObsScene = re.compile(r"(?:\$OBSscene\([\ ]*[\"\'](?P[^\"\']+)[\"\'][\ ]*(?:\,[\ ]*[\"\'](?P\d*)[\"\'][\ ]*)?\))", re.U) - RegObsSource = re.compile(r"(?P\$OBSsource\([\ ]*[\"\'](?P[^\"\']+)[\"\'][\ ]*\,[\ ]*[\"\'](?P[^\"\']*)[\"\'][\ ]*(?:\,[\ ]*[\"\'](?P[^\"\']*)[\"\'][\ ]*)?\))", re.U) - RegObsTmdScn = re.compile(r"(?P\$OBStimedScene\([\ ]*[\"\'](?P[^\"\']+)[\"\'][\ ]*\,[\ ]*[\"\'](?P[^\"\']+)[\"\'][\ ]*\,[\ ]*[\"\'](?P\d+)[\"\'][\ ]*\))", re.U) - RegObsTmdSrc = re.compile(r"(?P\$OBStimedSource\([\ ]*[\"\'](?P[^\"\']+)[\"\'][\ ]*\,[\ ]*[\"\'](?Ponoff|offon)[\"\'][\ ]*\,[\ ]*[\"\'](?P\d+)[\"\'][\ ]*(?:\,[\ ]*[\"\'](?P[^\"\']*)[\"\'][\ ]*)?\))", re.U) - - # End of Init - return + """ Initialize Script. """ + + # Globals + global RegObsScene + global RegObsSource + global RegObsTmdSrc + global RegObsTmdScn + global RegObsAudioVolume + + # Compile regexes in init + RegObsScene = re.compile(r"(?:\$OBSscene\([\ ]*[\"\'](?P[^\"\']+)[\"\'][\ ]*(?:\,[\ ]*[\"\'](?P\d*)[\"\'][\ ]*)?\))", re.U) + RegObsSource = re.compile(r"(?P\$OBSsource\([\ ]*[\"\'](?P[^\"\']+)[\"\'][\ ]*\,[\ ]*[\"\'](?P[^\"\']*)[\"\'][\ ]*(?:\,[\ ]*[\"\'](?P[^\"\']*)[\"\'][\ ]*)?\))", re.U) + RegObsTmdScn = re.compile(r"(?P\$OBStimedScene\([\ ]*[\"\'](?P[^\"\']+)[\"\'][\ ]*\,[\ ]*[\"\'](?P[^\"\']+)[\"\'][\ ]*\,[\ ]*[\"\'](?P\d+)[\"\'][\ ]*\))", re.U) + RegObsTmdSrc = re.compile(r"(?P\$OBStimedSource\([\ ]*[\"\'](?P[^\"\']+)[\"\'][\ ]*\,[\ ]*[\"\'](?Ponoff|offon)[\"\'][\ ]*\,[\ ]*[\"\'](?P\d+)[\"\'][\ ]*(?:\,[\ ]*[\"\'](?P[^\"\']*)[\"\'][\ ]*)?\))", re.U) + RegObsAudioVolume = re.compile(r"(?P\$OBSvolumeSet\([\ ]*[\"\'](?P[^\"\']+)[\"\'][\ ]*(?:\,[\ ]*[\"\'](?P\d*)[\"\'][\ ]*)?\))", re.U) + + # End of Init + return #--------------------------------------- # Parse parameters #--------------------------------------- def Parse(parseString, user, target, message): - """ Custom Parameter Parser. """ + """ Custom Parameter Parser. """ + + # $OBSscene("scene") parameter + # $OBSscene("scene", "delay") parameter + if "$OBSscene" in parseString: + + # Apply regex to verify correct parameter use + result = RegObsScene.search(parseString) + if result: + + # Get results from regex match + fullParameterMatch = result.group(0) + scene = result.group("scene") + delay = int(result.group("delay")) if result.group("delay") else None - # $OBSscene("scene") parameter - # $OBSscene("scene", "delay") parameter - if "$OBSscene" in parseString: + # Change to another scene, using threading + threading.Thread(target=ChangeToScene, args=(scene, delay)).start() - # Apply regex to verify correct parameter use - result = RegObsScene.search(parseString) - if result: + # Replace the whole parameter with an empty string + return parseString.replace(fullParameterMatch, "") - # Get results from regex match - fullParameterMatch = result.group(0) - scene = result.group("scene") - delay = int(result.group("delay")) if result.group("delay") else None + # $OBSsource("source", "enabled") + # $OBSsource("source", "enabled", "scene") + if "$OBSsource" in parseString: - # Change to another scene, using threading - threading.Thread(target=ChangeToScene, args=(scene, delay)).start() + # Apply regex to verify correct parameter use + result = RegObsSource.search(parseString) + if result: - # Replace the whole parameter with an empty string - return parseString.replace(fullParameterMatch, "") + # Get match groups from regex + fullParameterMatch = result.group(0) + source = result.group("source") + enabled = False if result.group("enabled").lower() == "false" else True + scene = result.group("scene") if result.group("scene") else None - # $OBSsource("source", "enabled") - # $OBSsource("source", "enabled", "scene") - if "$OBSsource" in parseString: + # Set source visibility, using threading + threading.Thread(target=SetSourceVisibility, args=(source, enabled, scene)).start() - # Apply regex to verify correct parameter use - result = RegObsSource.search(parseString) - if result: + # Replace the whole parameter with an empty string + return parseString.replace(fullParameterMatch, "") - # Get match groups from regex - fullParameterMatch = result.group(0) - source = result.group("source") - enabled = False if result.group("enabled").lower() == "false" else True - scene = result.group("scene") if result.group("scene") else None + # #OBStimedScene("scene_one", "scene_two", "delay") + if "$OBStimedScene" in parseString: - # Set source visibility, using threading - threading.Thread(target=SetSourceVisibility, args=(source, enabled, scene)).start() + # Apply regext to verify correct parameter use + result = RegObsTmdScn.search(parseString) + if result: - # Replace the whole parameter with an empty string - return parseString.replace(fullParameterMatch, "") + # Get match groups from regex + fullParameterMatch = result.group(0) + scene1 = result.group("s1") + scene2 = result.group("s2") + delay = int(result.group("delay")) if result.group("delay") else None - # #OBStimedScene("scene_one", "scene_two", "delay") - if "$OBStimedScene" in parseString: + # Change to scene one, then to two after set delay, using threading + threading.Thread(target=ChangeScenesTimed, args=(scene1, scene2, delay)).start() - # Apply regext to verify correct parameter use - result = RegObsTmdScn.search(parseString) - if result: + # Replace the whole parameter with an empty string + return parseString.replace(fullParameterMatch, "") - # Get match groups from regex - fullParameterMatch = result.group(0) - scene1 = result.group("s1") - scene2 = result.group("s2") - delay = int(result.group("delay")) if result.group("delay") else None + # $OBStimedSource("source", "mode", "delay") + # $OBStimedSource("source", "mode", "delay", "scene") + if "$OBStimedSource" in parseString: - # Change to scene one, then to two after set delay, using threading - threading.Thread(target=ChangeScenesTimed, args=(scene1, scene2, delay)).start() + # Apply regex to verify correct parameter use + result = RegObsTmdSrc.search(parseString) + if result: - # Replace the whole parameter with an empty string - return parseString.replace(fullParameterMatch, "") + # Get match groups from regex + fullParameterMatch = result.group(0) + source = result.group("source") + mode = result.group("mode") + delay = int(result.group("delay")) if result.group("delay") else None + scene = result.group("scene") if result.group("scene") else None - # $OBStimedSource("source", "mode", "delay") - # $OBStimedSource("source", "mode", "delay", "scene") - if "$OBStimedSource" in parseString: + # Start a new thread to disable the source again after amount of given seconds + threading.Thread(target=VisibilitySourceTimed, args=(source, mode, delay, scene)).start() - # Apply regex to verify correct parameter use - result = RegObsTmdSrc.search(parseString) - if result: + # Replace the whole parameter with an empty string + return parseString.replace(fullParameterMatch, "") - # Get match groups from regex - fullParameterMatch = result.group(0) - source = result.group("source") - mode = result.group("mode") - delay = int(result.group("delay")) if result.group("delay") else None - scene = result.group("scene") if result.group("scene") else None + # $OBSvolumeSet("source", "volume") + if "$OBSvolumeSet" in parseString: - # Start a new thread to disable the source again after amount of given seconds - threading.Thread(target=VisibilitySourceTimed, args=(source, mode, delay, scene)).start() + # Apply regex to verify correct parameter use + result = RegObsAudioVolume.search(parseString) + if result: - # Replace the whole parameter with an empty string - return parseString.replace(fullParameterMatch, "") + # Get match groups from regex + fullParameterMatch = result.group(0) + source = result.group("source") + volume = result.group("volume") + # Set source visibility, using threading + threading.Thread(target=SetAudioSourceVolume, args=(source, volume)).start() + # Replace the whole parameter with an empty string + return parseString.replace(fullParameterMatch, "") - # $OBSstop parameter - if "$OBSstop" in parseString: + # $OBSstop parameter + if "$OBSstop" in parseString: - # Call Stop streaming - Parent.StopOBSStreaming(CallbackLogger) + # Call Stop streaming + Parent.StopOBSStreaming(CallbackLogger) - # Replace the whole parameter with an empty string - return parseString.replace("$OBSstop", "") + # Replace the whole parameter with an empty string + return parseString.replace("$OBSstop", "") - # Return unaltered parseString - return parseString + # Return unaltered parseString + return parseString From 115ee53374729f5e2b0af1209abe08db815c867f Mon Sep 17 00:00:00 2001 From: wdpk Date: Sat, 20 Feb 2021 03:36:11 -1000 Subject: [PATCH 2/4] Update OBSRemoteParameters_StreamlabsParameter.py --- OBSRemoteParameters_StreamlabsParameter.py | 308 ++++++++++----------- 1 file changed, 154 insertions(+), 154 deletions(-) diff --git a/OBSRemoteParameters_StreamlabsParameter.py b/OBSRemoteParameters_StreamlabsParameter.py index 84b994c..c0423b3 100644 --- a/OBSRemoteParameters_StreamlabsParameter.py +++ b/OBSRemoteParameters_StreamlabsParameter.py @@ -7,18 +7,18 @@ Version - 1.4.0 - Added $OBSsetVolume set volume for given source, 1-100 - 1.3.0 - $OBStimedSource now has an onoff or offon mode and $OBSscene now can accept an optional delay. - All parameters now use threading in Python to execute actions. - 1.2.0 - Added $OBStimedScene swap to a given scene for a set period of time, then swap to another given scene. - Changed script name to _StreamlabsParameter to accomedate the change in the bot name. - 1.1.0 - Added $OBStimedSource enabled a given source for a set period of time - 1.0.0 - Initial release containing $OBSsource, $OBSscene and $OBSstop + 1.4.0 + Added $OBSsetVolume set volume for given source, 1-100 + 1.3.0 + $OBStimedSource now has an onoff or offon mode and $OBSscene now can accept an optional delay. + All parameters now use threading in Python to execute actions. + 1.2.0 + Added $OBStimedScene swap to a given scene for a set period of time, then swap to another given scene. + Changed script name to _StreamlabsParameter to accomedate the change in the bot name. + 1.1.0 + Added $OBStimedSource enabled a given source for a set period of time + 1.0.0 + Initial release containing $OBSsource, $OBSscene and $OBSstop """ @@ -57,194 +57,194 @@ # Functions #--------------------------------------- def OpenReadMe(): - """ Open the script readme file in users default .txt application. """ - os.startfile(ReadMeFile) - return + """ Open the script readme file in users default .txt application. """ + os.startfile(ReadMeFile) + return def CallbackLogger(response): - """ Logs callback error response in scripts logger. """ - parsedresponse = json.loads(response) - if parsedresponse["status"] == "error": - Parent.Log("OBS Remote", parsedresponse["error"]) - return + """ Logs callback error response in scripts logger. """ + parsedresponse = json.loads(response) + if parsedresponse["status"] == "error": + Parent.Log("OBS Remote", parsedresponse["error"]) + return def ChangeToScene(scene, delay=None): - """ Swaps to a given scene, optionally after given amount of seconds. """ - if delay: - time.sleep(delay) - Parent.SetOBSCurrentScene(scene, CallbackLogger) - return + """ Swaps to a given scene, optionally after given amount of seconds. """ + if delay: + time.sleep(delay) + Parent.SetOBSCurrentScene(scene, CallbackLogger) + return def SetSourceVisibility(source, enabled, scene=None): - """ Set the targeted source visibility optionally in a scene. """ - Parent.SetOBSSourceRender(source, enabled, scene, CallbackLogger) - return + """ Set the targeted source visibility optionally in a scene. """ + Parent.SetOBSSourceRender(source, enabled, scene, CallbackLogger) + return def ChangeScenesTimed(scene_one, scene_two, delay): - """ Swap to one scene then to another scene after a set delay. """ - Parent.SetOBSCurrentScene(scene_one, CallbackLogger) - if delay: - time.sleep(delay) - Parent.SetOBSCurrentScene(scene_two, CallbackLogger) - return + """ Swap to one scene then to another scene after a set delay. """ + Parent.SetOBSCurrentScene(scene_one, CallbackLogger) + if delay: + time.sleep(delay) + Parent.SetOBSCurrentScene(scene_two, CallbackLogger) + return def SetAudioSourceVolume(source, volume): - """ Set the targeted source to the volume """ - #clip numbers at 100 - output = 100 if (int(volume) > 100) else volume - #Volume function expects value between 0-1, divide by 100 for convenience of using whole numbers in chat commands - Parent.SetOBSVolume(source, float(output)/100, CallbackLogger) - return + """ Set the targeted source to the volume """ + #clip numbers at 100 + output = 100 if (int(volume) > 100) else volume + #Volume function expects value between 0-1, divide by 100 for convenience of using whole numbers in chat commands + Parent.SetOBSVolume(source, float(output)/100, CallbackLogger) + return def VisibilitySourceTimed(source, mode, delay, scene): - """ Disables a given source in optional scene after given amount of seconds. """ - # off - delay - off - if mode == "offon": - Parent.SetOBSSourceRender(source, False, scene, CallbackLogger) - if delay: - time.sleep(delay) - Parent.SetOBSSourceRender(source, True, scene, CallbackLogger) - # on - delay - off - else: - Parent.SetOBSSourceRender(source, True, scene, CallbackLogger) - if delay: - time.sleep(delay) - Parent.SetOBSSourceRender(source, False, scene, CallbackLogger) - # done - return + """ Disables a given source in optional scene after given amount of seconds. """ + # off - delay - off + if mode == "offon": + Parent.SetOBSSourceRender(source, False, scene, CallbackLogger) + if delay: + time.sleep(delay) + Parent.SetOBSSourceRender(source, True, scene, CallbackLogger) + # on - delay - off + else: + Parent.SetOBSSourceRender(source, True, scene, CallbackLogger) + if delay: + time.sleep(delay) + Parent.SetOBSSourceRender(source, False, scene, CallbackLogger) + # done + return #--------------------------------------- # Initialize data on load #--------------------------------------- def Init(): - """ Initialize Script. """ - - # Globals - global RegObsScene - global RegObsSource - global RegObsTmdSrc - global RegObsTmdScn - global RegObsAudioVolume - - # Compile regexes in init - RegObsScene = re.compile(r"(?:\$OBSscene\([\ ]*[\"\'](?P[^\"\']+)[\"\'][\ ]*(?:\,[\ ]*[\"\'](?P\d*)[\"\'][\ ]*)?\))", re.U) - RegObsSource = re.compile(r"(?P\$OBSsource\([\ ]*[\"\'](?P[^\"\']+)[\"\'][\ ]*\,[\ ]*[\"\'](?P[^\"\']*)[\"\'][\ ]*(?:\,[\ ]*[\"\'](?P[^\"\']*)[\"\'][\ ]*)?\))", re.U) - RegObsTmdScn = re.compile(r"(?P\$OBStimedScene\([\ ]*[\"\'](?P[^\"\']+)[\"\'][\ ]*\,[\ ]*[\"\'](?P[^\"\']+)[\"\'][\ ]*\,[\ ]*[\"\'](?P\d+)[\"\'][\ ]*\))", re.U) - RegObsTmdSrc = re.compile(r"(?P\$OBStimedSource\([\ ]*[\"\'](?P[^\"\']+)[\"\'][\ ]*\,[\ ]*[\"\'](?Ponoff|offon)[\"\'][\ ]*\,[\ ]*[\"\'](?P\d+)[\"\'][\ ]*(?:\,[\ ]*[\"\'](?P[^\"\']*)[\"\'][\ ]*)?\))", re.U) - RegObsAudioVolume = re.compile(r"(?P\$OBSvolumeSet\([\ ]*[\"\'](?P[^\"\']+)[\"\'][\ ]*(?:\,[\ ]*[\"\'](?P\d*)[\"\'][\ ]*)?\))", re.U) - - # End of Init - return + """ Initialize Script. """ + + # Globals + global RegObsScene + global RegObsSource + global RegObsTmdSrc + global RegObsTmdScn + global RegObsAudioVolume + + # Compile regexes in init + RegObsScene = re.compile(r"(?:\$OBSscene\([\ ]*[\"\'](?P[^\"\']+)[\"\'][\ ]*(?:\,[\ ]*[\"\'](?P\d*)[\"\'][\ ]*)?\))", re.U) + RegObsSource = re.compile(r"(?P\$OBSsource\([\ ]*[\"\'](?P[^\"\']+)[\"\'][\ ]*\,[\ ]*[\"\'](?P[^\"\']*)[\"\'][\ ]*(?:\,[\ ]*[\"\'](?P[^\"\']*)[\"\'][\ ]*)?\))", re.U) + RegObsTmdScn = re.compile(r"(?P\$OBStimedScene\([\ ]*[\"\'](?P[^\"\']+)[\"\'][\ ]*\,[\ ]*[\"\'](?P[^\"\']+)[\"\'][\ ]*\,[\ ]*[\"\'](?P\d+)[\"\'][\ ]*\))", re.U) + RegObsTmdSrc = re.compile(r"(?P\$OBStimedSource\([\ ]*[\"\'](?P[^\"\']+)[\"\'][\ ]*\,[\ ]*[\"\'](?Ponoff|offon)[\"\'][\ ]*\,[\ ]*[\"\'](?P\d+)[\"\'][\ ]*(?:\,[\ ]*[\"\'](?P[^\"\']*)[\"\'][\ ]*)?\))", re.U) + RegObsAudioVolume = re.compile(r"(?P\$OBSvolumeSet\([\ ]*[\"\'](?P[^\"\']+)[\"\'][\ ]*(?:\,[\ ]*[\"\'](?P\d*)[\"\'][\ ]*)?\))", re.U) + + # End of Init + return #--------------------------------------- # Parse parameters #--------------------------------------- def Parse(parseString, user, target, message): - """ Custom Parameter Parser. """ + """ Custom Parameter Parser. """ - # $OBSscene("scene") parameter - # $OBSscene("scene", "delay") parameter - if "$OBSscene" in parseString: + # $OBSscene("scene") parameter + # $OBSscene("scene", "delay") parameter + if "$OBSscene" in parseString: - # Apply regex to verify correct parameter use - result = RegObsScene.search(parseString) - if result: + # Apply regex to verify correct parameter use + result = RegObsScene.search(parseString) + if result: - # Get results from regex match - fullParameterMatch = result.group(0) - scene = result.group("scene") - delay = int(result.group("delay")) if result.group("delay") else None + # Get results from regex match + fullParameterMatch = result.group(0) + scene = result.group("scene") + delay = int(result.group("delay")) if result.group("delay") else None - # Change to another scene, using threading - threading.Thread(target=ChangeToScene, args=(scene, delay)).start() + # Change to another scene, using threading + threading.Thread(target=ChangeToScene, args=(scene, delay)).start() - # Replace the whole parameter with an empty string - return parseString.replace(fullParameterMatch, "") + # Replace the whole parameter with an empty string + return parseString.replace(fullParameterMatch, "") - # $OBSsource("source", "enabled") - # $OBSsource("source", "enabled", "scene") - if "$OBSsource" in parseString: + # $OBSsource("source", "enabled") + # $OBSsource("source", "enabled", "scene") + if "$OBSsource" in parseString: - # Apply regex to verify correct parameter use - result = RegObsSource.search(parseString) - if result: + # Apply regex to verify correct parameter use + result = RegObsSource.search(parseString) + if result: - # Get match groups from regex - fullParameterMatch = result.group(0) - source = result.group("source") - enabled = False if result.group("enabled").lower() == "false" else True - scene = result.group("scene") if result.group("scene") else None + # Get match groups from regex + fullParameterMatch = result.group(0) + source = result.group("source") + enabled = False if result.group("enabled").lower() == "false" else True + scene = result.group("scene") if result.group("scene") else None - # Set source visibility, using threading - threading.Thread(target=SetSourceVisibility, args=(source, enabled, scene)).start() + # Set source visibility, using threading + threading.Thread(target=SetSourceVisibility, args=(source, enabled, scene)).start() - # Replace the whole parameter with an empty string - return parseString.replace(fullParameterMatch, "") + # Replace the whole parameter with an empty string + return parseString.replace(fullParameterMatch, "") - # #OBStimedScene("scene_one", "scene_two", "delay") - if "$OBStimedScene" in parseString: + # #OBStimedScene("scene_one", "scene_two", "delay") + if "$OBStimedScene" in parseString: - # Apply regext to verify correct parameter use - result = RegObsTmdScn.search(parseString) - if result: + # Apply regext to verify correct parameter use + result = RegObsTmdScn.search(parseString) + if result: - # Get match groups from regex - fullParameterMatch = result.group(0) - scene1 = result.group("s1") - scene2 = result.group("s2") - delay = int(result.group("delay")) if result.group("delay") else None + # Get match groups from regex + fullParameterMatch = result.group(0) + scene1 = result.group("s1") + scene2 = result.group("s2") + delay = int(result.group("delay")) if result.group("delay") else None - # Change to scene one, then to two after set delay, using threading - threading.Thread(target=ChangeScenesTimed, args=(scene1, scene2, delay)).start() + # Change to scene one, then to two after set delay, using threading + threading.Thread(target=ChangeScenesTimed, args=(scene1, scene2, delay)).start() - # Replace the whole parameter with an empty string - return parseString.replace(fullParameterMatch, "") + # Replace the whole parameter with an empty string + return parseString.replace(fullParameterMatch, "") - # $OBStimedSource("source", "mode", "delay") - # $OBStimedSource("source", "mode", "delay", "scene") - if "$OBStimedSource" in parseString: + # $OBStimedSource("source", "mode", "delay") + # $OBStimedSource("source", "mode", "delay", "scene") + if "$OBStimedSource" in parseString: - # Apply regex to verify correct parameter use - result = RegObsTmdSrc.search(parseString) - if result: + # Apply regex to verify correct parameter use + result = RegObsTmdSrc.search(parseString) + if result: - # Get match groups from regex - fullParameterMatch = result.group(0) - source = result.group("source") - mode = result.group("mode") - delay = int(result.group("delay")) if result.group("delay") else None - scene = result.group("scene") if result.group("scene") else None + # Get match groups from regex + fullParameterMatch = result.group(0) + source = result.group("source") + mode = result.group("mode") + delay = int(result.group("delay")) if result.group("delay") else None + scene = result.group("scene") if result.group("scene") else None - # Start a new thread to disable the source again after amount of given seconds - threading.Thread(target=VisibilitySourceTimed, args=(source, mode, delay, scene)).start() + # Start a new thread to disable the source again after amount of given seconds + threading.Thread(target=VisibilitySourceTimed, args=(source, mode, delay, scene)).start() - # Replace the whole parameter with an empty string - return parseString.replace(fullParameterMatch, "") + # Replace the whole parameter with an empty string + return parseString.replace(fullParameterMatch, "") - # $OBSvolumeSet("source", "volume") - if "$OBSvolumeSet" in parseString: + # $OBSvolumeSet("source", "volume") + if "$OBSvolumeSet" in parseString: - # Apply regex to verify correct parameter use - result = RegObsAudioVolume.search(parseString) - if result: + # Apply regex to verify correct parameter use + result = RegObsAudioVolume.search(parseString) + if result: - # Get match groups from regex - fullParameterMatch = result.group(0) - source = result.group("source") - volume = result.group("volume") - # Set source visibility, using threading - threading.Thread(target=SetAudioSourceVolume, args=(source, volume)).start() - # Replace the whole parameter with an empty string - return parseString.replace(fullParameterMatch, "") + # Get match groups from regex + fullParameterMatch = result.group(0) + source = result.group("source") + volume = result.group("volume") + # Set source visibility, using threading + threading.Thread(target=SetAudioSourceVolume, args=(source, volume)).start() + # Replace the whole parameter with an empty string + return parseString.replace(fullParameterMatch, "") - # $OBSstop parameter - if "$OBSstop" in parseString: + # $OBSstop parameter + if "$OBSstop" in parseString: - # Call Stop streaming - Parent.StopOBSStreaming(CallbackLogger) + # Call Stop streaming + Parent.StopOBSStreaming(CallbackLogger) - # Replace the whole parameter with an empty string - return parseString.replace("$OBSstop", "") + # Replace the whole parameter with an empty string + return parseString.replace("$OBSstop", "") - # Return unaltered parseString - return parseString + # Return unaltered parseString + return parseString From 0743d937b3a238e216e8a27ee5fd89c60d9083d7 Mon Sep 17 00:00:00 2001 From: wdpk Date: Sat, 20 Feb 2021 03:41:57 -1000 Subject: [PATCH 3/4] remove excess trailing spaces --- OBSRemoteParameters_StreamlabsParameter.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/OBSRemoteParameters_StreamlabsParameter.py b/OBSRemoteParameters_StreamlabsParameter.py index c0423b3..402a6bd 100644 --- a/OBSRemoteParameters_StreamlabsParameter.py +++ b/OBSRemoteParameters_StreamlabsParameter.py @@ -148,7 +148,7 @@ def Parse(parseString, user, target, message): # Apply regex to verify correct parameter use result = RegObsScene.search(parseString) - if result: + if result: # Get results from regex match fullParameterMatch = result.group(0) @@ -176,7 +176,7 @@ def Parse(parseString, user, target, message): scene = result.group("scene") if result.group("scene") else None # Set source visibility, using threading - threading.Thread(target=SetSourceVisibility, args=(source, enabled, scene)).start() + threading.Thread(target=SetSourceVisibility, args=(source, enabled, scene)).start() # Replace the whole parameter with an empty string return parseString.replace(fullParameterMatch, "") @@ -233,7 +233,7 @@ def Parse(parseString, user, target, message): source = result.group("source") volume = result.group("volume") # Set source visibility, using threading - threading.Thread(target=SetAudioSourceVolume, args=(source, volume)).start() + threading.Thread(target=SetAudioSourceVolume, args=(source, volume)).start() # Replace the whole parameter with an empty string return parseString.replace(fullParameterMatch, "") From 9fa714fa535313b9905672e2b0ca656e64407124 Mon Sep 17 00:00:00 2001 From: wdpk Date: Sat, 20 Feb 2021 04:00:37 -1000 Subject: [PATCH 4/4] add info about new volume setting option --- readme.txt | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/readme.txt b/readme.txt index 6271730..766f3a0 100644 --- a/readme.txt +++ b/readme.txt @@ -145,10 +145,32 @@ $OBStimedSource("", "", "", "") containing containing single (') or double (") quotes for this parameter. +SET VOLUME OF SOURCE +=============================================================================== + +$OBSvolumeSet("", "") + + # Set the current volume for a given source. + + + + Name of the targeted source to set the visibility of. + This is a required argument and cannot be empty. The name has to match the + source name in OBS and is therefore case sensitive. All characters can be + used except names containing single (') or double (") quotes for this + parameter. + + + + Set the volume on values from 0-100. + This is a required argument and cannot be empty and needs to be a valid + number to be used. + + STOP STREAMING =============================================================================== $OBSstop No arugments required. Can be used for example for a trusted moderator to - stop streaming in case of an emergency. \ No newline at end of file + stop streaming in case of an emergency.