Skip to content

Commit

Permalink
Merge pull request #33 from StartAutomating/obs-powershell-sources
Browse files Browse the repository at this point in the history
obs-powershell 0.1.2
  • Loading branch information
StartAutomating authored Dec 16, 2022
2 parents 1f24ee7 + 372eb4e commit b0560e1
Show file tree
Hide file tree
Showing 263 changed files with 2,771 additions and 2,395 deletions.
66 changes: 9 additions & 57 deletions Assets/obs-powershell.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
## obs-powershell 0.1.2:

* New Commands
* Add-OBSBrowserSource (Fixes #24)
* Add-OBSDisplaySource (Fixes #25)
* Add-OBSMediaSource (Fixes #28)
* Clear-OBSScene (Fixes #27)
* New Methods
* OBS.GetSceneListResponse:
* .Remove()/.Delete() (Fixes #26)
* .Lock()/.Unlock() (Fixes #32)
* General Improvements
* Standardizing Parameter Naming (Fixes #30)
* Using GUIDs for RequestIDs (Fixes #29)
* Updated logo (Fixes #23)

---

## obs-powershell 0.1.1

* Connect-OBS now caches connections (Fixes #18)
Expand Down
29 changes: 29 additions & 0 deletions Commands/Clear-OBSScene.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
function Clear-OBSScene
{
<#
.SYNOPSIS
Clears a Scene in OBS
.DESCRIPTION
Clears a Scene in OBS.
All inputs will be removed from the scene.
This cannot be undone, so you will be prompted for confirmation.
.EXAMPLE
Clear-OBSScene -SceneName Scene
#>
[CmdletBinding(SupportsShouldProcess,ConfirmImpact='High')]
param(
# Name of the scene.
[Parameter(ValueFromPipelineByPropertyName)]
[string]
$SceneName
)

process {
if ($PSCmdlet.ShouldProcess("Clear $sceneName")) {
Get-OBSSceneItem -SceneName $SceneName |
Remove-OBSSceneItem
}
}
}
24 changes: 7 additions & 17 deletions Commands/Requests/Add-OBSInput.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,27 @@ param(
[Parameter(Mandatory,ValueFromPipelineByPropertyName)]
[ComponentModel.DefaultBindingProperty('sceneName')]
[string]
$sceneName,
$SceneName,
<# Name of the new input to created #>
[Parameter(Mandatory,ValueFromPipelineByPropertyName)]
[ComponentModel.DefaultBindingProperty('inputName')]
[string]
$inputName,
$InputName,
<# The kind of input to be created #>
[Parameter(Mandatory,ValueFromPipelineByPropertyName)]
[ComponentModel.DefaultBindingProperty('inputKind')]
[string]
$inputKind,
$InputKind,
<# Settings object to initialize the input with #>
[Parameter(ValueFromPipelineByPropertyName)]
[ComponentModel.DefaultBindingProperty('inputSettings')]
[PSObject]
$inputSettings,
$InputSettings,
<# Whether to set the created scene item to enabled or disabled #>
[Parameter(ValueFromPipelineByPropertyName)]
[ComponentModel.DefaultBindingProperty('sceneItemEnabled')]
[switch]
$sceneItemEnabled,
$SceneItemEnabled,
# If set, will return the information that would otherwise be sent to OBS.
[Parameter(ValueFromPipelineByPropertyName)]
[Alias('OutputRequest','OutputInput')]
Expand Down Expand Up @@ -98,24 +98,14 @@ process {
}
}
}


# If we don't have a request counter for this request type
if (-not $script:ObsRequestsCounts[$myRequestType]) {
# initialize it to zero.
$script:ObsRequestsCounts[$myRequestType] = 0
}
# Increment the counter for requests of this type
$script:ObsRequestsCounts[$myRequestType]++

# and make a request ID from that.
$myRequestId = "$myRequestType.$($script:ObsRequestsCounts[$myRequestType])"

$myRequestId = "$myRequestType.$([Guid]::newGuid())"

# Construct the payload object
$requestPayload = [Ordered]@{
# It must include a request ID
requestId = "$myRequestType.$($script:ObsRequestsCounts[$myRequestType])"
requestId = $myRequestId
# request type
requestType = $myRequestType
# and optional data
Expand Down
17 changes: 3 additions & 14 deletions Commands/Requests/Add-OBSProfile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ function Add-OBSProfile {
https://github.com/obsproject/obs-websocket/blob/master/docs/generated/protocol.md#createprofile
#>
[Reflection.AssemblyMetadata('OBS.WebSocket.RequestType', 'CreateProfile')]

param(
<# Name for the new profile #>
[Parameter(Mandatory,ValueFromPipelineByPropertyName)]
[ComponentModel.DefaultBindingProperty('profileName')]
[string]
$profileName,
$ProfileName,
# If set, will return the information that would otherwise be sent to OBS.
[Parameter(ValueFromPipelineByPropertyName)]
[Alias('OutputRequest','OutputInput')]
Expand Down Expand Up @@ -78,24 +77,14 @@ process {
}
}
}


# If we don't have a request counter for this request type
if (-not $script:ObsRequestsCounts[$myRequestType]) {
# initialize it to zero.
$script:ObsRequestsCounts[$myRequestType] = 0
}
# Increment the counter for requests of this type
$script:ObsRequestsCounts[$myRequestType]++

# and make a request ID from that.
$myRequestId = "$myRequestType.$($script:ObsRequestsCounts[$myRequestType])"

$myRequestId = "$myRequestType.$([Guid]::newGuid())"

# Construct the payload object
$requestPayload = [Ordered]@{
# It must include a request ID
requestId = "$myRequestType.$($script:ObsRequestsCounts[$myRequestType])"
requestId = $myRequestId
# request type
requestType = $myRequestType
# and optional data
Expand Down
17 changes: 3 additions & 14 deletions Commands/Requests/Add-OBSScene.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ function Add-OBSScene {
https://github.com/obsproject/obs-websocket/blob/master/docs/generated/protocol.md#createscene
#>
[Reflection.AssemblyMetadata('OBS.WebSocket.RequestType', 'CreateScene')]

param(
<# Name for the new scene #>
[Parameter(Mandatory,ValueFromPipelineByPropertyName)]
[ComponentModel.DefaultBindingProperty('sceneName')]
[string]
$sceneName,
$SceneName,
# If set, will return the information that would otherwise be sent to OBS.
[Parameter(ValueFromPipelineByPropertyName)]
[Alias('OutputRequest','OutputInput')]
Expand Down Expand Up @@ -78,24 +77,14 @@ process {
}
}
}


# If we don't have a request counter for this request type
if (-not $script:ObsRequestsCounts[$myRequestType]) {
# initialize it to zero.
$script:ObsRequestsCounts[$myRequestType] = 0
}
# Increment the counter for requests of this type
$script:ObsRequestsCounts[$myRequestType]++

# and make a request ID from that.
$myRequestId = "$myRequestType.$($script:ObsRequestsCounts[$myRequestType])"

$myRequestId = "$myRequestType.$([Guid]::newGuid())"

# Construct the payload object
$requestPayload = [Ordered]@{
# It must include a request ID
requestId = "$myRequestType.$($script:ObsRequestsCounts[$myRequestType])"
requestId = $myRequestId
# request type
requestType = $myRequestType
# and optional data
Expand Down
17 changes: 3 additions & 14 deletions Commands/Requests/Add-OBSSceneCollection.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@ function Add-OBSSceneCollection {
https://github.com/obsproject/obs-websocket/blob/master/docs/generated/protocol.md#createscenecollection
#>
[Reflection.AssemblyMetadata('OBS.WebSocket.RequestType', 'CreateSceneCollection')]

param(
<# Name for the new scene collection #>
[Parameter(Mandatory,ValueFromPipelineByPropertyName)]
[ComponentModel.DefaultBindingProperty('sceneCollectionName')]
[string]
$sceneCollectionName,
$SceneCollectionName,
# If set, will return the information that would otherwise be sent to OBS.
[Parameter(ValueFromPipelineByPropertyName)]
[Alias('OutputRequest','OutputInput')]
Expand Down Expand Up @@ -80,24 +79,14 @@ process {
}
}
}


# If we don't have a request counter for this request type
if (-not $script:ObsRequestsCounts[$myRequestType]) {
# initialize it to zero.
$script:ObsRequestsCounts[$myRequestType] = 0
}
# Increment the counter for requests of this type
$script:ObsRequestsCounts[$myRequestType]++

# and make a request ID from that.
$myRequestId = "$myRequestType.$($script:ObsRequestsCounts[$myRequestType])"

$myRequestId = "$myRequestType.$([Guid]::newGuid())"

# Construct the payload object
$requestPayload = [Ordered]@{
# It must include a request ID
requestId = "$myRequestType.$($script:ObsRequestsCounts[$myRequestType])"
requestId = $myRequestId
# request type
requestType = $myRequestType
# and optional data
Expand Down
21 changes: 6 additions & 15 deletions Commands/Requests/Add-OBSSceneItem.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,23 @@ function Add-OBSSceneItem {
#>
[Reflection.AssemblyMetadata('OBS.WebSocket.RequestType', 'CreateSceneItem')]
[Reflection.AssemblyMetadata('OBS.WebSocket.ExpectingResponse', $true)]
[Alias('Add-OBSSceneSource')]
param(
<# Name of the scene to create the new item in #>
[Parameter(Mandatory,ValueFromPipelineByPropertyName)]
[ComponentModel.DefaultBindingProperty('sceneName')]
[string]
$sceneName,
$SceneName,
<# Name of the source to add to the scene #>
[Parameter(Mandatory,ValueFromPipelineByPropertyName)]
[ComponentModel.DefaultBindingProperty('sourceName')]
[string]
$sourceName,
$SourceName,
<# Enable state to apply to the scene item on creation #>
[Parameter(ValueFromPipelineByPropertyName)]
[ComponentModel.DefaultBindingProperty('sceneItemEnabled')]
[switch]
$sceneItemEnabled,
$SceneItemEnabled,
# If set, will return the information that would otherwise be sent to OBS.
[Parameter(ValueFromPipelineByPropertyName)]
[Alias('OutputRequest','OutputInput')]
Expand Down Expand Up @@ -90,24 +91,14 @@ process {
}
}
}


# If we don't have a request counter for this request type
if (-not $script:ObsRequestsCounts[$myRequestType]) {
# initialize it to zero.
$script:ObsRequestsCounts[$myRequestType] = 0
}
# Increment the counter for requests of this type
$script:ObsRequestsCounts[$myRequestType]++

# and make a request ID from that.
$myRequestId = "$myRequestType.$($script:ObsRequestsCounts[$myRequestType])"

$myRequestId = "$myRequestType.$([Guid]::newGuid())"

# Construct the payload object
$requestPayload = [Ordered]@{
# It must include a request ID
requestId = "$myRequestType.$($script:ObsRequestsCounts[$myRequestType])"
requestId = $myRequestId
# request type
requestType = $myRequestType
# and optional data
Expand Down
Loading

0 comments on commit b0560e1

Please sign in to comment.