Skip to content

Commit b0560e1

Browse files
Merge pull request #33 from StartAutomating/obs-powershell-sources
obs-powershell 0.1.2
2 parents 1f24ee7 + 372eb4e commit b0560e1

File tree

263 files changed

+2771
-2395
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

263 files changed

+2771
-2395
lines changed

Assets/obs-powershell.svg

Lines changed: 9 additions & 57 deletions
Loading

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
## obs-powershell 0.1.2:
2+
3+
* New Commands
4+
* Add-OBSBrowserSource (Fixes #24)
5+
* Add-OBSDisplaySource (Fixes #25)
6+
* Add-OBSMediaSource (Fixes #28)
7+
* Clear-OBSScene (Fixes #27)
8+
* New Methods
9+
* OBS.GetSceneListResponse:
10+
* .Remove()/.Delete() (Fixes #26)
11+
* .Lock()/.Unlock() (Fixes #32)
12+
* General Improvements
13+
* Standardizing Parameter Naming (Fixes #30)
14+
* Using GUIDs for RequestIDs (Fixes #29)
15+
* Updated logo (Fixes #23)
16+
17+
---
18+
119
## obs-powershell 0.1.1
220

321
* Connect-OBS now caches connections (Fixes #18)

Commands/Clear-OBSScene.ps1

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
function Clear-OBSScene
2+
{
3+
<#
4+
.SYNOPSIS
5+
Clears a Scene in OBS
6+
.DESCRIPTION
7+
Clears a Scene in OBS.
8+
9+
All inputs will be removed from the scene.
10+
11+
This cannot be undone, so you will be prompted for confirmation.
12+
.EXAMPLE
13+
Clear-OBSScene -SceneName Scene
14+
#>
15+
[CmdletBinding(SupportsShouldProcess,ConfirmImpact='High')]
16+
param(
17+
# Name of the scene.
18+
[Parameter(ValueFromPipelineByPropertyName)]
19+
[string]
20+
$SceneName
21+
)
22+
23+
process {
24+
if ($PSCmdlet.ShouldProcess("Clear $sceneName")) {
25+
Get-OBSSceneItem -SceneName $SceneName |
26+
Remove-OBSSceneItem
27+
}
28+
}
29+
}

Commands/Requests/Add-OBSInput.ps1

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,27 @@ param(
1919
[Parameter(Mandatory,ValueFromPipelineByPropertyName)]
2020
[ComponentModel.DefaultBindingProperty('sceneName')]
2121
[string]
22-
$sceneName,
22+
$SceneName,
2323
<# Name of the new input to created #>
2424
[Parameter(Mandatory,ValueFromPipelineByPropertyName)]
2525
[ComponentModel.DefaultBindingProperty('inputName')]
2626
[string]
27-
$inputName,
27+
$InputName,
2828
<# The kind of input to be created #>
2929
[Parameter(Mandatory,ValueFromPipelineByPropertyName)]
3030
[ComponentModel.DefaultBindingProperty('inputKind')]
3131
[string]
32-
$inputKind,
32+
$InputKind,
3333
<# Settings object to initialize the input with #>
3434
[Parameter(ValueFromPipelineByPropertyName)]
3535
[ComponentModel.DefaultBindingProperty('inputSettings')]
3636
[PSObject]
37-
$inputSettings,
37+
$InputSettings,
3838
<# Whether to set the created scene item to enabled or disabled #>
3939
[Parameter(ValueFromPipelineByPropertyName)]
4040
[ComponentModel.DefaultBindingProperty('sceneItemEnabled')]
4141
[switch]
42-
$sceneItemEnabled,
42+
$SceneItemEnabled,
4343
# If set, will return the information that would otherwise be sent to OBS.
4444
[Parameter(ValueFromPipelineByPropertyName)]
4545
[Alias('OutputRequest','OutputInput')]
@@ -98,24 +98,14 @@ process {
9898
}
9999
}
100100
}
101-
102101

103-
# If we don't have a request counter for this request type
104-
if (-not $script:ObsRequestsCounts[$myRequestType]) {
105-
# initialize it to zero.
106-
$script:ObsRequestsCounts[$myRequestType] = 0
107-
}
108-
# Increment the counter for requests of this type
109-
$script:ObsRequestsCounts[$myRequestType]++
110-
111102
# and make a request ID from that.
112-
$myRequestId = "$myRequestType.$($script:ObsRequestsCounts[$myRequestType])"
113-
103+
$myRequestId = "$myRequestType.$([Guid]::newGuid())"
114104

115105
# Construct the payload object
116106
$requestPayload = [Ordered]@{
117107
# It must include a request ID
118-
requestId = "$myRequestType.$($script:ObsRequestsCounts[$myRequestType])"
108+
requestId = $myRequestId
119109
# request type
120110
requestType = $myRequestType
121111
# and optional data

Commands/Requests/Add-OBSProfile.ps1

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,12 @@ function Add-OBSProfile {
1313
https://github.com/obsproject/obs-websocket/blob/master/docs/generated/protocol.md#createprofile
1414
#>
1515
[Reflection.AssemblyMetadata('OBS.WebSocket.RequestType', 'CreateProfile')]
16-
1716
param(
1817
<# Name for the new profile #>
1918
[Parameter(Mandatory,ValueFromPipelineByPropertyName)]
2019
[ComponentModel.DefaultBindingProperty('profileName')]
2120
[string]
22-
$profileName,
21+
$ProfileName,
2322
# If set, will return the information that would otherwise be sent to OBS.
2423
[Parameter(ValueFromPipelineByPropertyName)]
2524
[Alias('OutputRequest','OutputInput')]
@@ -78,24 +77,14 @@ process {
7877
}
7978
}
8079
}
81-
8280

83-
# If we don't have a request counter for this request type
84-
if (-not $script:ObsRequestsCounts[$myRequestType]) {
85-
# initialize it to zero.
86-
$script:ObsRequestsCounts[$myRequestType] = 0
87-
}
88-
# Increment the counter for requests of this type
89-
$script:ObsRequestsCounts[$myRequestType]++
90-
9181
# and make a request ID from that.
92-
$myRequestId = "$myRequestType.$($script:ObsRequestsCounts[$myRequestType])"
93-
82+
$myRequestId = "$myRequestType.$([Guid]::newGuid())"
9483

9584
# Construct the payload object
9685
$requestPayload = [Ordered]@{
9786
# It must include a request ID
98-
requestId = "$myRequestType.$($script:ObsRequestsCounts[$myRequestType])"
87+
requestId = $myRequestId
9988
# request type
10089
requestType = $myRequestType
10190
# and optional data

Commands/Requests/Add-OBSScene.ps1

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,12 @@ function Add-OBSScene {
1313
https://github.com/obsproject/obs-websocket/blob/master/docs/generated/protocol.md#createscene
1414
#>
1515
[Reflection.AssemblyMetadata('OBS.WebSocket.RequestType', 'CreateScene')]
16-
1716
param(
1817
<# Name for the new scene #>
1918
[Parameter(Mandatory,ValueFromPipelineByPropertyName)]
2019
[ComponentModel.DefaultBindingProperty('sceneName')]
2120
[string]
22-
$sceneName,
21+
$SceneName,
2322
# If set, will return the information that would otherwise be sent to OBS.
2423
[Parameter(ValueFromPipelineByPropertyName)]
2524
[Alias('OutputRequest','OutputInput')]
@@ -78,24 +77,14 @@ process {
7877
}
7978
}
8079
}
81-
8280

83-
# If we don't have a request counter for this request type
84-
if (-not $script:ObsRequestsCounts[$myRequestType]) {
85-
# initialize it to zero.
86-
$script:ObsRequestsCounts[$myRequestType] = 0
87-
}
88-
# Increment the counter for requests of this type
89-
$script:ObsRequestsCounts[$myRequestType]++
90-
9181
# and make a request ID from that.
92-
$myRequestId = "$myRequestType.$($script:ObsRequestsCounts[$myRequestType])"
93-
82+
$myRequestId = "$myRequestType.$([Guid]::newGuid())"
9483

9584
# Construct the payload object
9685
$requestPayload = [Ordered]@{
9786
# It must include a request ID
98-
requestId = "$myRequestType.$($script:ObsRequestsCounts[$myRequestType])"
87+
requestId = $myRequestId
9988
# request type
10089
requestType = $myRequestType
10190
# and optional data

Commands/Requests/Add-OBSSceneCollection.ps1

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,12 @@ function Add-OBSSceneCollection {
1515
https://github.com/obsproject/obs-websocket/blob/master/docs/generated/protocol.md#createscenecollection
1616
#>
1717
[Reflection.AssemblyMetadata('OBS.WebSocket.RequestType', 'CreateSceneCollection')]
18-
1918
param(
2019
<# Name for the new scene collection #>
2120
[Parameter(Mandatory,ValueFromPipelineByPropertyName)]
2221
[ComponentModel.DefaultBindingProperty('sceneCollectionName')]
2322
[string]
24-
$sceneCollectionName,
23+
$SceneCollectionName,
2524
# If set, will return the information that would otherwise be sent to OBS.
2625
[Parameter(ValueFromPipelineByPropertyName)]
2726
[Alias('OutputRequest','OutputInput')]
@@ -80,24 +79,14 @@ process {
8079
}
8180
}
8281
}
83-
8482

85-
# If we don't have a request counter for this request type
86-
if (-not $script:ObsRequestsCounts[$myRequestType]) {
87-
# initialize it to zero.
88-
$script:ObsRequestsCounts[$myRequestType] = 0
89-
}
90-
# Increment the counter for requests of this type
91-
$script:ObsRequestsCounts[$myRequestType]++
92-
9383
# and make a request ID from that.
94-
$myRequestId = "$myRequestType.$($script:ObsRequestsCounts[$myRequestType])"
95-
84+
$myRequestId = "$myRequestType.$([Guid]::newGuid())"
9685

9786
# Construct the payload object
9887
$requestPayload = [Ordered]@{
9988
# It must include a request ID
100-
requestId = "$myRequestType.$($script:ObsRequestsCounts[$myRequestType])"
89+
requestId = $myRequestId
10190
# request type
10291
requestType = $myRequestType
10392
# and optional data

Commands/Requests/Add-OBSSceneItem.ps1

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,23 @@ function Add-OBSSceneItem {
1616
#>
1717
[Reflection.AssemblyMetadata('OBS.WebSocket.RequestType', 'CreateSceneItem')]
1818
[Reflection.AssemblyMetadata('OBS.WebSocket.ExpectingResponse', $true)]
19+
[Alias('Add-OBSSceneSource')]
1920
param(
2021
<# Name of the scene to create the new item in #>
2122
[Parameter(Mandatory,ValueFromPipelineByPropertyName)]
2223
[ComponentModel.DefaultBindingProperty('sceneName')]
2324
[string]
24-
$sceneName,
25+
$SceneName,
2526
<# Name of the source to add to the scene #>
2627
[Parameter(Mandatory,ValueFromPipelineByPropertyName)]
2728
[ComponentModel.DefaultBindingProperty('sourceName')]
2829
[string]
29-
$sourceName,
30+
$SourceName,
3031
<# Enable state to apply to the scene item on creation #>
3132
[Parameter(ValueFromPipelineByPropertyName)]
3233
[ComponentModel.DefaultBindingProperty('sceneItemEnabled')]
3334
[switch]
34-
$sceneItemEnabled,
35+
$SceneItemEnabled,
3536
# If set, will return the information that would otherwise be sent to OBS.
3637
[Parameter(ValueFromPipelineByPropertyName)]
3738
[Alias('OutputRequest','OutputInput')]
@@ -90,24 +91,14 @@ process {
9091
}
9192
}
9293
}
93-
9494

95-
# If we don't have a request counter for this request type
96-
if (-not $script:ObsRequestsCounts[$myRequestType]) {
97-
# initialize it to zero.
98-
$script:ObsRequestsCounts[$myRequestType] = 0
99-
}
100-
# Increment the counter for requests of this type
101-
$script:ObsRequestsCounts[$myRequestType]++
102-
10395
# and make a request ID from that.
104-
$myRequestId = "$myRequestType.$($script:ObsRequestsCounts[$myRequestType])"
105-
96+
$myRequestId = "$myRequestType.$([Guid]::newGuid())"
10697

10798
# Construct the payload object
10899
$requestPayload = [Ordered]@{
109100
# It must include a request ID
110-
requestId = "$myRequestType.$($script:ObsRequestsCounts[$myRequestType])"
101+
requestId = $myRequestId
111102
# request type
112103
requestType = $myRequestType
113104
# and optional data

0 commit comments

Comments
 (0)