mirror of
https://github.com/onyx-and-iris/obsws-cli.git
synced 2025-05-16 22:40:23 +01:00
add toggle and visible commands to scene-item group
update README minor bump
This commit is contained in:
parent
88635ed152
commit
5852dd4836
34
README.md
34
README.md
@ -90,6 +90,13 @@ obsws-cli scene switch LIVE
|
|||||||
|
|
||||||
#### Scene Item
|
#### Scene Item
|
||||||
|
|
||||||
|
- list: List all items in a scene.
|
||||||
|
- args: <scene_name>
|
||||||
|
|
||||||
|
```console
|
||||||
|
obsws-cli scene-item list LIVE
|
||||||
|
```
|
||||||
|
|
||||||
- show: Show an item in a scene.
|
- show: Show an item in a scene.
|
||||||
- args: <scene_name> <item_name>
|
- args: <scene_name> <item_name>
|
||||||
|
|
||||||
@ -104,15 +111,29 @@ obsws-cli scene-item show START "Colour Source"
|
|||||||
obsws-cli scene-item hide START "Colour Source"
|
obsws-cli scene-item hide START "Colour Source"
|
||||||
```
|
```
|
||||||
|
|
||||||
- list: List all items in a scene.
|
- toggle: Toggle an item in a scene.
|
||||||
- args: <scene_name>
|
- args: <scene_name> <item_name>
|
||||||
|
|
||||||
```console
|
```console
|
||||||
obsws-cli scene-item list LIVE
|
obsws-cli scene-item toggle START "Colour Source"
|
||||||
|
```
|
||||||
|
|
||||||
|
- visible: Check if an item in a scene is visible.
|
||||||
|
- args: <scene_name> <item_name>
|
||||||
|
|
||||||
|
```console
|
||||||
|
obsws-cli scene-item visible START "Colour Source"
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Group
|
#### Group
|
||||||
|
|
||||||
|
- list: List groups in a scene.
|
||||||
|
- args: <scene_name>
|
||||||
|
|
||||||
|
```console
|
||||||
|
obsws-cli group list START
|
||||||
|
```
|
||||||
|
|
||||||
- show: Show a group in a scene.
|
- show: Show a group in a scene.
|
||||||
- args: <scene_name> <group_name>
|
- args: <scene_name> <group_name>
|
||||||
|
|
||||||
@ -127,13 +148,6 @@ obsws-cli group show START "test_group"
|
|||||||
obsws-cli group hide START "test_group"
|
obsws-cli group hide START "test_group"
|
||||||
```
|
```
|
||||||
|
|
||||||
- list: List groups in a scene.
|
|
||||||
- args: <scene_name>
|
|
||||||
|
|
||||||
```console
|
|
||||||
obsws-cli group list START
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Input
|
#### Input
|
||||||
|
|
||||||
- list: List all inputs.
|
- list: List all inputs.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# SPDX-FileCopyrightText: 2025-present onyx-and-iris <code@onyxandiris.online>
|
# SPDX-FileCopyrightText: 2025-present onyx-and-iris <code@onyxandiris.online>
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
__version__ = "0.3.0"
|
__version__ = "0.4.0"
|
||||||
|
@ -15,6 +15,21 @@ def main():
|
|||||||
"""Control groups in OBS scenes."""
|
"""Control groups in OBS scenes."""
|
||||||
|
|
||||||
|
|
||||||
|
@app.command('list | ls')
|
||||||
|
def list(ctx: typer.Context, scene_name: str):
|
||||||
|
"""List groups in a scene."""
|
||||||
|
try:
|
||||||
|
resp = ctx.obj['obsws'].get_scene_item_list(scene_name)
|
||||||
|
groups = (
|
||||||
|
item.get('sourceName') for item in resp.scene_items if item.get('isGroup')
|
||||||
|
)
|
||||||
|
typer.echo('\n'.join(groups))
|
||||||
|
except obsws.error.OBSSDKRequestError as e:
|
||||||
|
if e.code == 600:
|
||||||
|
raise ObswsCliBadParameter(str(e)) from e
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
def _get_group(group_name: str, resp: DataclassProtocol) -> dict | None:
|
def _get_group(group_name: str, resp: DataclassProtocol) -> dict | None:
|
||||||
"""Get a group from the scene item list response."""
|
"""Get a group from the scene item list response."""
|
||||||
group = next(
|
group = next(
|
||||||
@ -64,18 +79,3 @@ def hide(ctx: typer.Context, scene_name: str, group_name: str):
|
|||||||
if e.code == 600:
|
if e.code == 600:
|
||||||
raise ObswsCliBadParameter(str(e)) from e
|
raise ObswsCliBadParameter(str(e)) from e
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
@app.command('list | ls')
|
|
||||||
def list(ctx: typer.Context, scene_name: str):
|
|
||||||
"""List groups in a scene."""
|
|
||||||
try:
|
|
||||||
resp = ctx.obj['obsws'].get_scene_item_list(scene_name)
|
|
||||||
groups = (
|
|
||||||
item.get('sourceName') for item in resp.scene_items if item.get('isGroup')
|
|
||||||
)
|
|
||||||
typer.echo('\n'.join(groups))
|
|
||||||
except obsws.error.OBSSDKRequestError as e:
|
|
||||||
if e.code == 600:
|
|
||||||
raise ObswsCliBadParameter(str(e)) from e
|
|
||||||
raise
|
|
||||||
|
@ -58,7 +58,7 @@ def status(ctx: typer.Context):
|
|||||||
typer.echo('Recording is not in progress.')
|
typer.echo('Recording is not in progress.')
|
||||||
|
|
||||||
|
|
||||||
@app.command()
|
@app.command('toggle | tg')
|
||||||
def toggle(ctx: typer.Context):
|
def toggle(ctx: typer.Context):
|
||||||
"""Toggle recording."""
|
"""Toggle recording."""
|
||||||
active, _ = _get_recording_status(ctx)
|
active, _ = _get_recording_status(ctx)
|
||||||
|
@ -14,6 +14,19 @@ def main():
|
|||||||
"""Control items in OBS scenes."""
|
"""Control items in OBS scenes."""
|
||||||
|
|
||||||
|
|
||||||
|
@app.command('list | ls')
|
||||||
|
def list(ctx: typer.Context, scene_name: str):
|
||||||
|
"""List all items in a scene."""
|
||||||
|
try:
|
||||||
|
resp = ctx.obj['obsws'].get_scene_item_list(scene_name)
|
||||||
|
items = (item.get('sourceName') for item in resp.scene_items)
|
||||||
|
typer.echo('\n'.join(items))
|
||||||
|
except obsws.error.OBSSDKRequestError as e:
|
||||||
|
if e.code == 600:
|
||||||
|
raise ObswsCliBadParameter(str(e)) from e
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
@app.command()
|
@app.command()
|
||||||
def show(ctx: typer.Context, scene_name: str, item_name: str):
|
def show(ctx: typer.Context, scene_name: str, item_name: str):
|
||||||
"""Show an item in a scene."""
|
"""Show an item in a scene."""
|
||||||
@ -48,13 +61,40 @@ def hide(ctx: typer.Context, scene_name: str, item_name: str):
|
|||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
@app.command('list | ls')
|
@app.command('toggle | tg')
|
||||||
def list(ctx: typer.Context, scene_name: str):
|
def toggle(ctx: typer.Context, scene_name: str, item_name: str):
|
||||||
"""List all items in a scene."""
|
"""Toggle an item in a scene."""
|
||||||
try:
|
try:
|
||||||
resp = ctx.obj['obsws'].get_scene_item_list(scene_name)
|
resp = ctx.obj['obsws'].get_scene_item_id(scene_name, item_name)
|
||||||
items = (item.get('sourceName') for item in resp.scene_items)
|
enabled = ctx.obj['obsws'].get_scene_item_enabled(
|
||||||
typer.echo('\n'.join(items))
|
scene_name=scene_name,
|
||||||
|
item_id=int(resp.scene_item_id),
|
||||||
|
)
|
||||||
|
|
||||||
|
new_state = not enabled.scene_item_enabled
|
||||||
|
ctx.obj['obsws'].set_scene_item_enabled(
|
||||||
|
scene_name=scene_name,
|
||||||
|
item_id=int(resp.scene_item_id),
|
||||||
|
enabled=new_state,
|
||||||
|
)
|
||||||
|
except obsws.error.OBSSDKRequestError as e:
|
||||||
|
if e.code == 600:
|
||||||
|
raise ObswsCliBadParameter(str(e)) from e
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
@app.command()
|
||||||
|
def visible(ctx: typer.Context, scene_name: str, item_name: str):
|
||||||
|
"""Check if an item in a scene is visible."""
|
||||||
|
try:
|
||||||
|
resp = ctx.obj['obsws'].get_scene_item_id(scene_name, item_name)
|
||||||
|
enabled = ctx.obj['obsws'].get_scene_item_enabled(
|
||||||
|
scene_name=scene_name,
|
||||||
|
item_id=int(resp.scene_item_id),
|
||||||
|
)
|
||||||
|
typer.echo(
|
||||||
|
f"Item '{item_name}' in scene '{scene_name}' is currently {'visible' if enabled.scene_item_enabled else 'hidden'}."
|
||||||
|
)
|
||||||
except obsws.error.OBSSDKRequestError as e:
|
except obsws.error.OBSSDKRequestError as e:
|
||||||
if e.code == 600:
|
if e.code == 600:
|
||||||
raise ObswsCliBadParameter(str(e)) from e
|
raise ObswsCliBadParameter(str(e)) from e
|
||||||
|
Loading…
x
Reference in New Issue
Block a user