mirror of
https://github.com/onyx-and-iris/obsws-cli.git
synced 2025-06-27 22:10:29 +01:00
add --uuid flags to input list, scene list and sceneitem list
This commit is contained in:
parent
e9b3106aa6
commit
39f1b01926
@ -27,6 +27,7 @@ def list_(
|
|||||||
colour: Annotated[bool, typer.Option(help='Filter by colour source type.')] = False,
|
colour: Annotated[bool, typer.Option(help='Filter by colour source type.')] = False,
|
||||||
ffmpeg: Annotated[bool, typer.Option(help='Filter by ffmpeg source type.')] = False,
|
ffmpeg: Annotated[bool, typer.Option(help='Filter by ffmpeg source type.')] = False,
|
||||||
vlc: Annotated[bool, typer.Option(help='Filter by VLC source type.')] = False,
|
vlc: Annotated[bool, typer.Option(help='Filter by VLC source type.')] = False,
|
||||||
|
uuid: Annotated[bool, typer.Option(help='Show UUIDs of scenes')] = False,
|
||||||
):
|
):
|
||||||
"""List all inputs."""
|
"""List all inputs."""
|
||||||
resp = ctx.obj.get_input_list()
|
resp = ctx.obj.get_input_list()
|
||||||
@ -47,7 +48,7 @@ def list_(
|
|||||||
|
|
||||||
inputs = sorted(
|
inputs = sorted(
|
||||||
(
|
(
|
||||||
(input_.get('inputName'), input_.get('inputKind'))
|
(input_.get('inputName'), input_.get('inputKind'), input_.get('inputUuid'))
|
||||||
for input_ in filter(
|
for input_ in filter(
|
||||||
lambda input_: any(kind in input_.get('inputKind') for kind in kinds),
|
lambda input_: any(kind in input_.get('inputKind') for kind in kinds),
|
||||||
resp.inputs,
|
resp.inputs,
|
||||||
@ -61,15 +62,24 @@ def list_(
|
|||||||
raise typer.Exit()
|
raise typer.Exit()
|
||||||
|
|
||||||
table = Table(title='Inputs', padding=(0, 2))
|
table = Table(title='Inputs', padding=(0, 2))
|
||||||
columns = [
|
if uuid:
|
||||||
('Input Name', 'left', 'cyan'),
|
columns = [
|
||||||
('Kind', 'center', 'cyan'),
|
('Input Name', 'left', 'cyan'),
|
||||||
('Muted', 'center', None),
|
('Kind', 'center', 'cyan'),
|
||||||
]
|
('Muted', 'center', None),
|
||||||
|
('UUID', 'left', 'cyan'),
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
table.title += ' (UUIDs hidden)'
|
||||||
|
columns = [
|
||||||
|
('Input Name', 'left', 'cyan'),
|
||||||
|
('Kind', 'center', 'cyan'),
|
||||||
|
('Muted', 'center', None),
|
||||||
|
]
|
||||||
for column, justify, style in columns:
|
for column, justify, style in columns:
|
||||||
table.add_column(column, justify=justify, style=style)
|
table.add_column(column, justify=justify, style=style)
|
||||||
|
|
||||||
for input_name, input_kind in inputs:
|
for input_name, input_kind, input_uuid in inputs:
|
||||||
input_mark = ''
|
input_mark = ''
|
||||||
if any(
|
if any(
|
||||||
kind in input_kind
|
kind in input_kind
|
||||||
@ -78,11 +88,19 @@ def list_(
|
|||||||
input_muted = ctx.obj.get_input_mute(name=input_name).input_muted
|
input_muted = ctx.obj.get_input_mute(name=input_name).input_muted
|
||||||
input_mark = ':white_heavy_check_mark:' if input_muted else ':x:'
|
input_mark = ':white_heavy_check_mark:' if input_muted else ':x:'
|
||||||
|
|
||||||
table.add_row(
|
if uuid:
|
||||||
input_name,
|
table.add_row(
|
||||||
util.snakecase_to_titlecase(input_kind),
|
input_name,
|
||||||
input_mark,
|
util.snakecase_to_titlecase(input_kind),
|
||||||
)
|
input_mark,
|
||||||
|
input_uuid,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
table.add_row(
|
||||||
|
input_name,
|
||||||
|
util.snakecase_to_titlecase(input_kind),
|
||||||
|
input_mark,
|
||||||
|
)
|
||||||
|
|
||||||
out_console.print(table)
|
out_console.print(table)
|
||||||
|
|
||||||
|
@ -20,7 +20,10 @@ def main():
|
|||||||
|
|
||||||
|
|
||||||
@app.command('list | ls')
|
@app.command('list | ls')
|
||||||
def list_(ctx: typer.Context):
|
def list_(
|
||||||
|
ctx: typer.Context,
|
||||||
|
uuid: Annotated[bool, typer.Option(help='Show UUIDs of scenes')] = False,
|
||||||
|
):
|
||||||
"""List all scenes."""
|
"""List all scenes."""
|
||||||
resp = ctx.obj.get_scene_list()
|
resp = ctx.obj.get_scene_list()
|
||||||
scenes = (
|
scenes = (
|
||||||
@ -28,19 +31,41 @@ def list_(ctx: typer.Context):
|
|||||||
for scene in reversed(resp.scenes)
|
for scene in reversed(resp.scenes)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
active_scene = ctx.obj.get_current_program_scene().scene_name
|
||||||
|
|
||||||
table = Table(title='Scenes', padding=(0, 2))
|
table = Table(title='Scenes', padding=(0, 2))
|
||||||
columns = [
|
if uuid:
|
||||||
('Scene Name', 'left', 'cyan'),
|
columns = [
|
||||||
('UUID', 'left', 'cyan'),
|
('Scene Name', 'left', 'cyan'),
|
||||||
]
|
('Active', 'center', None),
|
||||||
|
('UUID', 'left', 'cyan'),
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
table.title += ' (UUIDs hidden)'
|
||||||
|
columns = [
|
||||||
|
('Scene Name', 'left', 'cyan'),
|
||||||
|
('Active', 'center', None),
|
||||||
|
]
|
||||||
for column, justify, style in columns:
|
for column, justify, style in columns:
|
||||||
table.add_column(column, justify=justify, style=style)
|
table.add_column(column, justify=justify, style=style)
|
||||||
|
|
||||||
for scene_name, scene_uuid in scenes:
|
for scene_name, scene_uuid in scenes:
|
||||||
table.add_row(
|
if scene_name == active_scene:
|
||||||
scene_name,
|
scene_output = f'[bold green]{scene_name}[/bold green]'
|
||||||
scene_uuid,
|
else:
|
||||||
)
|
scene_output = f'[dim]{scene_name}[/dim]'
|
||||||
|
|
||||||
|
if uuid:
|
||||||
|
table.add_row(
|
||||||
|
scene_output,
|
||||||
|
':white_heavy_check_mark:' if scene_name == active_scene else '',
|
||||||
|
scene_uuid,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
table.add_row(
|
||||||
|
scene_output,
|
||||||
|
':white_heavy_check_mark:' if scene_name == active_scene else '',
|
||||||
|
)
|
||||||
|
|
||||||
out_console.print(table)
|
out_console.print(table)
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
from typing import Annotated, Optional
|
from typing import Annotated, Optional
|
||||||
|
|
||||||
import obsws_python as obsws
|
|
||||||
import typer
|
import typer
|
||||||
from rich.console import Console
|
from rich.console import Console
|
||||||
from rich.table import Table
|
from rich.table import Table
|
||||||
@ -30,6 +29,7 @@ def list_(
|
|||||||
help='Scene name to list items for',
|
help='Scene name to list items for',
|
||||||
),
|
),
|
||||||
] = None,
|
] = None,
|
||||||
|
uuid: Annotated[bool, typer.Option(help='Show UUIDs of scene items')] = False,
|
||||||
):
|
):
|
||||||
"""List all items in a scene."""
|
"""List all items in a scene."""
|
||||||
if not scene_name:
|
if not scene_name:
|
||||||
@ -47,6 +47,7 @@ def list_(
|
|||||||
item.get('sourceName'),
|
item.get('sourceName'),
|
||||||
item.get('isGroup'),
|
item.get('isGroup'),
|
||||||
item.get('sceneItemEnabled'),
|
item.get('sceneItemEnabled'),
|
||||||
|
item.get('sourceUuid', 'N/A'), # Include source UUID
|
||||||
)
|
)
|
||||||
for item in resp.scene_items
|
for item in resp.scene_items
|
||||||
),
|
),
|
||||||
@ -58,17 +59,27 @@ def list_(
|
|||||||
raise typer.Exit()
|
raise typer.Exit()
|
||||||
|
|
||||||
table = Table(title=f'Items in Scene: {scene_name}', padding=(0, 2))
|
table = Table(title=f'Items in Scene: {scene_name}', padding=(0, 2))
|
||||||
columns = [
|
if uuid:
|
||||||
('Item ID', 'center', 'cyan'),
|
columns = [
|
||||||
('Item Name', 'left', 'cyan'),
|
('Item ID', 'center', 'cyan'),
|
||||||
('In Group', 'left', 'cyan'),
|
('Item Name', 'left', 'cyan'),
|
||||||
('Enabled', 'center', None),
|
('In Group', 'left', 'cyan'),
|
||||||
]
|
('Enabled', 'center', None),
|
||||||
|
('UUID', 'left', 'cyan'),
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
table.title += ' (UUIDs hidden)'
|
||||||
|
columns = [
|
||||||
|
('Item ID', 'center', 'cyan'),
|
||||||
|
('Item Name', 'left', 'cyan'),
|
||||||
|
('In Group', 'left', 'cyan'),
|
||||||
|
('Enabled', 'center', None),
|
||||||
|
]
|
||||||
# Add columns to the table
|
# Add columns to the table
|
||||||
for column, justify, style in columns:
|
for column, justify, style in columns:
|
||||||
table.add_column(column, justify=justify, style=style)
|
table.add_column(column, justify=justify, style=style)
|
||||||
|
|
||||||
for item_id, item_name, is_group, is_enabled in items:
|
for item_id, item_name, is_group, is_enabled, source_uuid in items:
|
||||||
if is_group:
|
if is_group:
|
||||||
resp = ctx.obj.get_group_scene_item_list(item_name)
|
resp = ctx.obj.get_group_scene_item_list(item_name)
|
||||||
group_items = sorted(
|
group_items = sorted(
|
||||||
@ -77,27 +88,53 @@ def list_(
|
|||||||
gi.get('sceneItemId'),
|
gi.get('sceneItemId'),
|
||||||
gi.get('sourceName'),
|
gi.get('sourceName'),
|
||||||
gi.get('sceneItemEnabled'),
|
gi.get('sceneItemEnabled'),
|
||||||
|
gi.get('sourceUuid', 'N/A'), # Include source UUID
|
||||||
)
|
)
|
||||||
for gi in resp.scene_items
|
for gi in resp.scene_items
|
||||||
),
|
),
|
||||||
key=lambda x: x[0], # Sort by sceneItemId
|
key=lambda x: x[0], # Sort by sceneItemId
|
||||||
)
|
)
|
||||||
for group_item_id, group_item_name, group_item_enabled in group_items:
|
for (
|
||||||
table.add_row(
|
group_item_id,
|
||||||
str(group_item_id),
|
group_item_name,
|
||||||
group_item_name,
|
group_item_enabled,
|
||||||
item_name,
|
group_item_source_uuid,
|
||||||
':white_heavy_check_mark:'
|
) in group_items:
|
||||||
if is_enabled and group_item_enabled
|
if uuid:
|
||||||
else ':x:',
|
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:',
|
||||||
|
group_item_source_uuid,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
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:
|
else:
|
||||||
table.add_row(
|
if uuid:
|
||||||
str(item_id),
|
table.add_row(
|
||||||
item_name,
|
str(item_id),
|
||||||
'',
|
item_name,
|
||||||
':white_heavy_check_mark:' if is_enabled else ':x:',
|
'',
|
||||||
)
|
':white_heavy_check_mark:' if is_enabled else ':x:',
|
||||||
|
source_uuid,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
table.add_row(
|
||||||
|
str(item_id),
|
||||||
|
item_name,
|
||||||
|
'',
|
||||||
|
':white_heavy_check_mark:' if is_enabled else ':x:',
|
||||||
|
)
|
||||||
|
|
||||||
out_console.print(table)
|
out_console.print(table)
|
||||||
|
|
||||||
@ -122,7 +159,9 @@ def _validate_sources(
|
|||||||
else:
|
else:
|
||||||
if not validate.item_in_scene_item_list(ctx, scene_name, item_name):
|
if not validate.item_in_scene_item_list(ctx, scene_name, item_name):
|
||||||
err_console.print(
|
err_console.print(
|
||||||
f'Item [yellow]{item_name}[/yellow] not found in scene [yellow]{scene_name}[/yellow].'
|
f'Item [yellow]{item_name}[/yellow] not found in scene [yellow]{scene_name}[/yellow]. Is the item in a group? '
|
||||||
|
f'If so use the [yellow]--group[/yellow] option to specify the parent group.\n'
|
||||||
|
'Use `obsws-cli sceneitem list` for a list of items in the scene.'
|
||||||
)
|
)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -146,18 +185,7 @@ def _get_scene_name_and_item_id(
|
|||||||
)
|
)
|
||||||
raise typer.Exit(1)
|
raise typer.Exit(1)
|
||||||
else:
|
else:
|
||||||
try:
|
resp = ctx.obj.get_scene_item_id(scene_name, item_name)
|
||||||
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 [yellow]{item_name}[/yellow] not found in scene [yellow]{scene_name}[/yellow]. Is the item in a group? '
|
|
||||||
'If so use the --group option to specify the parent group. '
|
|
||||||
'Use `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
|
scene_item_id = resp.scene_item_id
|
||||||
|
|
||||||
return scene_name, scene_item_id
|
return scene_name, scene_item_id
|
||||||
|
Loading…
x
Reference in New Issue
Block a user