-
Notifications
You must be signed in to change notification settings - Fork 3
New Feature for OBS chatbot control - Source Audio Level #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
wdpk
wants to merge
4
commits into
Consoletation:master
Choose a base branch
from
wdpk:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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. | ||
| 1.1.0 | ||
| Added $OBStimedSource enabled a given source for a set period of time | ||
| 1.0.0 | ||
|
|
@@ -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,6 +51,7 @@ | |
| RegObsSource = None | ||
| RegObsTmdSrc = None | ||
| RegObsTmdScn = None | ||
| RegObsAudioVolume = None | ||
|
|
||
| #--------------------------------------- | ||
| # Functions | ||
|
|
@@ -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 | ||
|
|
@@ -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 | ||
|
|
@@ -135,7 +148,7 @@ def Parse(parseString, user, target, message): | |
|
|
||
| # Apply regex to verify correct parameter use | ||
| result = RegObsScene.search(parseString) | ||
| if result: | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
|
|
@@ -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, "") | ||
|
|
@@ -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: | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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