mirror of
https://github.com/onyx-and-iris/obsws-cli.git
synced 2025-08-07 20:21:48 +00:00
Compare commits
No commits in common. "b9d2afb10852a822b155397a7ddac912322fabe9" and "530daced5695f59627fed8688d9b5edddc9a3fb6" have entirely different histories.
b9d2afb108
...
530daced56
@ -5,12 +5,6 @@ All notable changes to this project will be documented in this file.
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
# [0.14.2] - 2025-05-29
|
||||
|
||||
### Changed
|
||||
|
||||
- The --parent flag for sceneitem commands has been renamed to --group. See [Scene Item](https://github.com/onyx-and-iris/obsws-cli/tree/main?tab=readme-ov-file#scene-item)
|
||||
|
||||
# [0.14.0] - 2025-05-27
|
||||
|
||||
### Added
|
||||
|
14
README.md
14
README.md
@ -111,7 +111,7 @@ obsws-cli sceneitem list LIVE
|
||||
- flags:
|
||||
|
||||
*optional*
|
||||
- --group: Parent group name
|
||||
- --parent: Parent group name
|
||||
- args: <scene_name> <item_name>
|
||||
|
||||
```console
|
||||
@ -122,7 +122,7 @@ obsws-cli sceneitem show START "Colour Source"
|
||||
- flags:
|
||||
|
||||
*optional*
|
||||
- --group: Parent group name
|
||||
- --parent: Parent group name
|
||||
- args: <scene_name> <item_name>
|
||||
|
||||
```console
|
||||
@ -133,29 +133,29 @@ obsws-cli sceneitem hide START "Colour Source"
|
||||
- flags:
|
||||
|
||||
*optional*
|
||||
- --group: Parent group name
|
||||
- --parent: Parent group name
|
||||
- args: <scene_name> <item_name>
|
||||
|
||||
```console
|
||||
obsws-cli sceneitem toggle --group=test_group START "Colour Source 3"
|
||||
obsws-cli sceneitem toggle --parent=test_group START "Colour Source 3"
|
||||
```
|
||||
|
||||
- visible: Check if an item in a scene is visible.
|
||||
- flags:
|
||||
|
||||
*optional*
|
||||
- --group: Parent group name
|
||||
- --parent: Parent group name
|
||||
- args: <scene_name> <item_name>
|
||||
|
||||
```console
|
||||
obsws-cli sceneitem visible --group=test_group START "Colour Source 4"
|
||||
obsws-cli sceneitem visible --parent=test_group START "Colour Source 4"
|
||||
```
|
||||
|
||||
- transform: Set the transform of an item in a scene.
|
||||
- flags:
|
||||
|
||||
*optional*
|
||||
- --group: Parent group name.
|
||||
- --parent: Parent group name.
|
||||
|
||||
- --alignment: Alignment of the item in the scene
|
||||
- --bounds-alignment: Bounds alignment of the item in the scene
|
||||
|
@ -1,4 +1,4 @@
|
||||
# SPDX-FileCopyrightText: 2025-present onyx-and-iris <code@onyxandiris.online>
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
__version__ = "0.14.2"
|
||||
__version__ = "0.14.1"
|
||||
|
@ -23,7 +23,7 @@ def list(ctx: typer.Context, source_name: str):
|
||||
"""List filters for a source."""
|
||||
try:
|
||||
resp = ctx.obj.get_source_filter_list(source_name)
|
||||
except obsws.error.OBSSDKRequestError as e:
|
||||
except obsws.error.OBSSDKError as e:
|
||||
if e.code == 600:
|
||||
err_console.print(f"No source was found by the name of '{source_name}'.")
|
||||
raise typer.Exit(1)
|
||||
|
@ -3,7 +3,6 @@
|
||||
from collections.abc import Callable
|
||||
from typing import Annotated, Optional
|
||||
|
||||
import obsws_python as obsws
|
||||
import typer
|
||||
from rich.console import Console
|
||||
from rich.table import Table
|
||||
@ -37,59 +36,17 @@ def list(
|
||||
raise typer.Exit(1)
|
||||
|
||||
resp = ctx.obj.get_scene_item_list(scene_name)
|
||||
items = sorted(
|
||||
(
|
||||
(
|
||||
item.get('sceneItemId'),
|
||||
item.get('sourceName'),
|
||||
item.get('isGroup'),
|
||||
item.get('sceneItemEnabled'),
|
||||
)
|
||||
for item in resp.scene_items
|
||||
),
|
||||
key=lambda x: x[0], # Sort by sceneItemId
|
||||
)
|
||||
items = [item.get('sourceName') for item in resp.scene_items]
|
||||
|
||||
if not items:
|
||||
out_console.print(f"No items found in scene '{scene_name}'.")
|
||||
return
|
||||
|
||||
table = Table(title=f'Items in Scene: {scene_name}', padding=(0, 2))
|
||||
for column in ('Item ID', 'Item Name', 'In Group', 'Enabled'):
|
||||
table.add_column(
|
||||
column, justify='left' if column == 'Item Name' else 'center', style='cyan'
|
||||
)
|
||||
table.add_column('Item Name', justify='left', style='cyan')
|
||||
|
||||
for item_id, item_name, is_group, is_enabled in items:
|
||||
if is_group:
|
||||
resp = ctx.obj.get_group_scene_item_list(item_name)
|
||||
group_items = sorted(
|
||||
(
|
||||
(
|
||||
gi.get('sceneItemId'),
|
||||
gi.get('sourceName'),
|
||||
gi.get('sceneItemEnabled'),
|
||||
)
|
||||
for gi in resp.scene_items
|
||||
),
|
||||
key=lambda x: x[0], # Sort by sceneItemId
|
||||
)
|
||||
for group_item_id, group_item_name, group_item_enabled in group_items:
|
||||
table.add_row(
|
||||
str(group_item_id),
|
||||
group_item_name,
|
||||
item_name,
|
||||
':white_heavy_check_mark:'
|
||||
if is_enabled and group_item_enabled
|
||||
else ':x:',
|
||||
)
|
||||
else:
|
||||
table.add_row(
|
||||
str(item_id),
|
||||
item_name,
|
||||
'',
|
||||
':white_heavy_check_mark:' if is_enabled else ':x:',
|
||||
)
|
||||
for item in items:
|
||||
table.add_row(item)
|
||||
|
||||
out_console.print(table)
|
||||
|
||||
@ -103,16 +60,16 @@ def _validate_scene_name_and_item_name(
|
||||
ctx: typer.Context,
|
||||
scene_name: str,
|
||||
item_name: str,
|
||||
group: Optional[str] = None,
|
||||
parent: Optional[str] = None,
|
||||
):
|
||||
if not validate.scene_in_scenes(ctx, scene_name):
|
||||
err_console.print(f"Scene '{scene_name}' not found.")
|
||||
raise typer.Exit(1)
|
||||
|
||||
if group:
|
||||
if not validate.item_in_scene_item_list(ctx, scene_name, group):
|
||||
if parent:
|
||||
if not validate.item_in_scene_item_list(ctx, scene_name, parent):
|
||||
err_console.print(
|
||||
f"Parent group '{group}' not found in scene '{scene_name}'."
|
||||
f"Parent group '{parent}' not found in scene '{scene_name}'."
|
||||
)
|
||||
raise typer.Exit(1)
|
||||
else:
|
||||
@ -122,38 +79,26 @@ def _validate_scene_name_and_item_name(
|
||||
)
|
||||
raise typer.Exit(1)
|
||||
|
||||
return func(ctx, scene_name, item_name, group)
|
||||
return func(ctx, scene_name, item_name, parent)
|
||||
|
||||
return wrapper
|
||||
|
||||
|
||||
def _get_scene_name_and_item_id(
|
||||
ctx: typer.Context, scene_name: str, item_name: str, group: Optional[str] = None
|
||||
ctx: typer.Context, scene_name: str, item_name: str, parent: Optional[str] = None
|
||||
):
|
||||
"""Get the scene name and item ID for the given scene and item name."""
|
||||
if group:
|
||||
resp = ctx.obj.get_group_scene_item_list(group)
|
||||
if parent:
|
||||
resp = ctx.obj.get_group_scene_item_list(parent)
|
||||
for item in resp.scene_items:
|
||||
if item.get('sourceName') == item_name:
|
||||
scene_name = group
|
||||
scene_name = parent
|
||||
scene_item_id = item.get('sceneItemId')
|
||||
break
|
||||
else:
|
||||
err_console.print(f"Item '{item_name}' not found in group '{group}'.")
|
||||
err_console.print(f"Item '{item_name}' not found in group '{parent}'.")
|
||||
raise typer.Exit(1)
|
||||
else:
|
||||
try:
|
||||
resp = ctx.obj.get_scene_item_id(scene_name, item_name)
|
||||
except obsws.error.OBSSDKRequestError as e:
|
||||
if e.code == 600:
|
||||
err_console.print(
|
||||
f"Item '{item_name}' not found in scene '{scene_name}'. Is the item in a group? "
|
||||
'If so use the --group option to specify the parent group. '
|
||||
'See `obsws-cli sceneitem list` for a list of items in the scene.'
|
||||
)
|
||||
raise typer.Exit(1)
|
||||
else:
|
||||
raise
|
||||
scene_item_id = resp.scene_item_id
|
||||
|
||||
return scene_name, scene_item_id
|
||||
@ -165,11 +110,11 @@ def show(
|
||||
ctx: typer.Context,
|
||||
scene_name: str,
|
||||
item_name: str,
|
||||
group: Annotated[Optional[str], typer.Option(help='Parent group name')] = None,
|
||||
parent: Annotated[Optional[str], typer.Option(help='Parent group name')] = None,
|
||||
):
|
||||
"""Show an item in a scene."""
|
||||
scene_name, scene_item_id = _get_scene_name_and_item_id(
|
||||
ctx, scene_name, item_name, group
|
||||
ctx, scene_name, item_name, parent
|
||||
)
|
||||
|
||||
ctx.obj.set_scene_item_enabled(
|
||||
@ -178,15 +123,6 @@ def show(
|
||||
enabled=True,
|
||||
)
|
||||
|
||||
if group:
|
||||
out_console.print(
|
||||
f"Item '{item_name}' in group '{group}' in scene '{scene_name}' has been shown."
|
||||
)
|
||||
else:
|
||||
# If not in a parent group, just show the scene name
|
||||
# This is to avoid confusion with the parent group name
|
||||
# which is not the same as the scene name
|
||||
# and is not needed in this case
|
||||
out_console.print(f"Item '{item_name}' in scene '{scene_name}' has been shown.")
|
||||
|
||||
|
||||
@ -196,11 +132,11 @@ def hide(
|
||||
ctx: typer.Context,
|
||||
scene_name: str,
|
||||
item_name: str,
|
||||
group: Annotated[Optional[str], typer.Option(help='Parent group name')] = None,
|
||||
parent: Annotated[Optional[str], typer.Option(help='Parent group name')] = None,
|
||||
):
|
||||
"""Hide an item in a scene."""
|
||||
scene_name, scene_item_id = _get_scene_name_and_item_id(
|
||||
ctx, scene_name, item_name, group
|
||||
ctx, scene_name, item_name, parent
|
||||
)
|
||||
|
||||
ctx.obj.set_scene_item_enabled(
|
||||
@ -209,18 +145,7 @@ def hide(
|
||||
enabled=False,
|
||||
)
|
||||
|
||||
if group:
|
||||
out_console.print(
|
||||
f"Item '{item_name}' in group '{group}' in scene '{scene_name}' has been hidden."
|
||||
)
|
||||
else:
|
||||
# If not in a parent group, just show the scene name
|
||||
# This is to avoid confusion with the parent group name
|
||||
# which is not the same as the scene name
|
||||
# and is not needed in this case
|
||||
out_console.print(
|
||||
f"Item '{item_name}' in scene '{scene_name}' has been hidden."
|
||||
)
|
||||
out_console.print(f"Item '{item_name}' in scene '{scene_name}' has been hidden.")
|
||||
|
||||
|
||||
@_validate_scene_name_and_item_name
|
||||
@ -229,17 +154,17 @@ def toggle(
|
||||
ctx: typer.Context,
|
||||
scene_name: str,
|
||||
item_name: str,
|
||||
group: Annotated[Optional[str], typer.Option(help='Parent group name')] = None,
|
||||
parent: Annotated[Optional[str], typer.Option(help='Parent group name')] = None,
|
||||
):
|
||||
"""Toggle an item in a scene."""
|
||||
if not validate.scene_in_scenes(ctx, scene_name):
|
||||
err_console.print(f"Scene '{scene_name}' not found.")
|
||||
raise typer.Exit(1)
|
||||
|
||||
if group:
|
||||
if not validate.item_in_scene_item_list(ctx, scene_name, group):
|
||||
if parent:
|
||||
if not validate.item_in_scene_item_list(ctx, scene_name, parent):
|
||||
err_console.print(
|
||||
f"Parent group '{group}' not found in scene '{scene_name}'."
|
||||
f"Parent group '{parent}' not found in scene '{scene_name}'."
|
||||
)
|
||||
raise typer.Exit(1)
|
||||
else:
|
||||
@ -248,7 +173,7 @@ def toggle(
|
||||
raise typer.Exit(1)
|
||||
|
||||
scene_name, scene_item_id = _get_scene_name_and_item_id(
|
||||
ctx, scene_name, item_name, group
|
||||
ctx, scene_name, item_name, parent
|
||||
)
|
||||
|
||||
enabled = ctx.obj.get_scene_item_enabled(
|
||||
@ -263,27 +188,8 @@ def toggle(
|
||||
enabled=new_state,
|
||||
)
|
||||
|
||||
if group:
|
||||
if new_state:
|
||||
out_console.print(
|
||||
f"Item '{item_name}' in group '{group}' in scene '{scene_name}' has been shown."
|
||||
)
|
||||
else:
|
||||
out_console.print(
|
||||
f"Item '{item_name}' in group '{group}' in scene '{scene_name}' has been hidden."
|
||||
)
|
||||
else:
|
||||
# If not in a parent group, just show the scene name
|
||||
# This is to avoid confusion with the parent group name
|
||||
# which is not the same as the scene name
|
||||
# and is not needed in this case
|
||||
if new_state:
|
||||
out_console.print(
|
||||
f"Item '{item_name}' in scene '{scene_name}' has been shown."
|
||||
)
|
||||
else:
|
||||
out_console.print(
|
||||
f"Item '{item_name}' in scene '{scene_name}' has been hidden."
|
||||
f"Item '{item_name}' in scene '{scene_name}' has been {'shown' if new_state else 'hidden'}."
|
||||
)
|
||||
|
||||
|
||||
@ -293,13 +199,13 @@ def visible(
|
||||
ctx: typer.Context,
|
||||
scene_name: str,
|
||||
item_name: str,
|
||||
group: Annotated[Optional[str], typer.Option(help='Parent group name')] = None,
|
||||
parent: Annotated[Optional[str], typer.Option(help='Parent group name')] = None,
|
||||
):
|
||||
"""Check if an item in a scene is visible."""
|
||||
if group:
|
||||
if not validate.item_in_scene_item_list(ctx, scene_name, group):
|
||||
if parent:
|
||||
if not validate.item_in_scene_item_list(ctx, scene_name, parent):
|
||||
err_console.print(
|
||||
f"Parent group '{group}' not found in scene '{scene_name}'."
|
||||
f"Parent group '{parent}' not found in scene '{scene_name}'."
|
||||
)
|
||||
raise typer.Exit(1)
|
||||
else:
|
||||
@ -309,7 +215,7 @@ def visible(
|
||||
|
||||
old_scene_name = scene_name
|
||||
scene_name, scene_item_id = _get_scene_name_and_item_id(
|
||||
ctx, scene_name, item_name, group
|
||||
ctx, scene_name, item_name, parent
|
||||
)
|
||||
|
||||
enabled = ctx.obj.get_scene_item_enabled(
|
||||
@ -317,9 +223,9 @@ def visible(
|
||||
item_id=int(scene_item_id),
|
||||
)
|
||||
|
||||
if group:
|
||||
if parent:
|
||||
out_console.print(
|
||||
f"Item '{item_name}' in group '{group}' in scene '{old_scene_name}' is currently {'visible' if enabled.scene_item_enabled else 'hidden'}."
|
||||
f"Item '{item_name}' in group '{parent}' in scene '{old_scene_name}' is currently {'visible' if enabled.scene_item_enabled else 'hidden'}."
|
||||
)
|
||||
else:
|
||||
# If not in a parent group, just show the scene name
|
||||
@ -337,7 +243,7 @@ def transform(
|
||||
ctx: typer.Context,
|
||||
scene_name: str,
|
||||
item_name: str,
|
||||
group: Annotated[Optional[str], typer.Option(help='Parent group name')] = None,
|
||||
parent: Annotated[Optional[str], typer.Option(help='Parent group name')] = None,
|
||||
alignment: Annotated[
|
||||
Optional[int], typer.Option(help='Alignment of the item in the scene')
|
||||
] = None,
|
||||
@ -385,10 +291,10 @@ def transform(
|
||||
] = None,
|
||||
):
|
||||
"""Set the transform of an item in a scene."""
|
||||
if group:
|
||||
if not validate.item_in_scene_item_list(ctx, scene_name, group):
|
||||
if parent:
|
||||
if not validate.item_in_scene_item_list(ctx, scene_name, parent):
|
||||
err_console.print(
|
||||
f"Parent group '{group}' not found in scene '{scene_name}'."
|
||||
f"Parent group '{parent}' not found in scene '{scene_name}'."
|
||||
)
|
||||
raise typer.Exit(1)
|
||||
else:
|
||||
@ -398,7 +304,7 @@ def transform(
|
||||
|
||||
old_scene_name = scene_name
|
||||
scene_name, scene_item_id = _get_scene_name_and_item_id(
|
||||
ctx, scene_name, item_name, group
|
||||
ctx, scene_name, item_name, parent
|
||||
)
|
||||
|
||||
transform = {}
|
||||
@ -443,9 +349,9 @@ def transform(
|
||||
transform=transform,
|
||||
)
|
||||
|
||||
if group:
|
||||
if parent:
|
||||
out_console.print(
|
||||
f"Item '{item_name}' in group '{group}' in scene '{old_scene_name}' has been transformed."
|
||||
f"Item '{item_name}' in group '{parent}' in scene '{old_scene_name}' has been transformed."
|
||||
)
|
||||
else:
|
||||
# If not in a parent group, just show the scene name
|
||||
|
Loading…
x
Reference in New Issue
Block a user