Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 34 additions & 5 deletions OBSRemoteParameters_StreamlabsParameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@

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 _StreamlabsSystem to accomedate the change in the bot name.
Changed script name to _StreamlabsParameter to accomedate the change in the bot name.
Comment on lines -15 to +17
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the script is named _StreamlabsParameter.py ? Not sure if this was a typo

1.1.0
Added $OBStimedSource enabled a given source for a set period of time
1.0.0
Expand All @@ -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
Expand All @@ -49,6 +51,7 @@
RegObsSource = None
RegObsTmdSrc = None
RegObsTmdScn = None
RegObsAudioVolume = None

#---------------------------------------
# Functions
Expand Down Expand Up @@ -85,6 +88,14 @@ def ChangeScenesTimed(scene_one, scene_two, 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
Expand Down Expand Up @@ -113,12 +124,14 @@ def Init():
global RegObsSource
global RegObsTmdSrc
global RegObsTmdScn

global RegObsAudioVolume

# Compile regexes in init
RegObsScene = re.compile(r"(?:\$OBSscene\([\ ]*[\"\'](?P<scene>[^\"\']+)[\"\'][\ ]*(?:\,[\ ]*[\"\'](?P<delay>\d*)[\"\'][\ ]*)?\))", re.U)
RegObsSource = re.compile(r"(?P<full>\$OBSsource\([\ ]*[\"\'](?P<source>[^\"\']+)[\"\'][\ ]*\,[\ ]*[\"\'](?P<enabled>[^\"\']*)[\"\'][\ ]*(?:\,[\ ]*[\"\'](?P<scene>[^\"\']*)[\"\'][\ ]*)?\))", re.U)
RegObsTmdScn = re.compile(r"(?P<full>\$OBStimedScene\([\ ]*[\"\'](?P<s1>[^\"\']+)[\"\'][\ ]*\,[\ ]*[\"\'](?P<s2>[^\"\']+)[\"\'][\ ]*\,[\ ]*[\"\'](?P<delay>\d+)[\"\'][\ ]*\))", re.U)
RegObsTmdSrc = re.compile(r"(?P<full>\$OBStimedSource\([\ ]*[\"\'](?P<source>[^\"\']+)[\"\'][\ ]*\,[\ ]*[\"\'](?P<mode>onoff|offon)[\"\'][\ ]*\,[\ ]*[\"\'](?P<delay>\d+)[\"\'][\ ]*(?:\,[\ ]*[\"\'](?P<scene>[^\"\']*)[\"\'][\ ]*)?\))", re.U)
RegObsAudioVolume = re.compile(r"(?P<full>\$OBSvolumeSet\([\ ]*[\"\'](?P<source>[^\"\']+)[\"\'][\ ]*(?:\,[\ ]*[\"\'](?P<volume>\d*)[\"\'][\ ]*)?\))", re.U)

# End of Init
return
Expand All @@ -135,7 +148,7 @@ def Parse(parseString, user, target, message):

# Apply regex to verify correct parameter use
result = RegObsScene.search(parseString)
if result:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removing trailing spaces

if result:

# Get results from regex match
fullParameterMatch = result.group(0)
Expand Down Expand Up @@ -163,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, "")
Expand Down Expand Up @@ -208,6 +221,22 @@ def Parse(parseString, user, target, message):
# Replace the whole parameter with an empty string
return parseString.replace(fullParameterMatch, "")

# $OBSvolumeSet("source", "volume")
if "$OBSvolumeSet" in parseString:

# 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, "")

# $OBSstop parameter
if "$OBSstop" in parseString:

Expand Down
24 changes: 23 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,32 @@ $OBStimedSource("<source>", "<mode>", "<delay>", "<scene>")
containing containing single (') or double (") quotes for this parameter.


SET VOLUME OF SOURCE
===============================================================================

$OBSvolumeSet("<source>", "<volume>")

# Set the current volume for a given source.

<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.

<volume>

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.
stop streaming in case of an emergency.