mirror of
https://github.com/onyx-and-iris/obsws-cli.git
synced 2026-04-07 01:23:35 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8bec6908e5 | |||
| 2c03b28fc6 | |||
| f1e29e0d4f |
@@ -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.24.3'
|
__version__ = '0.24.4'
|
||||||
|
|||||||
@@ -34,8 +34,6 @@ class RootTyperAliasGroup(typer.core.TyperGroup):
|
|||||||
cmd_name = 'record'
|
cmd_name = 'record'
|
||||||
case 'rb':
|
case 'rb':
|
||||||
cmd_name = 'replaybuffer'
|
cmd_name = 'replaybuffer'
|
||||||
case 'set':
|
|
||||||
cmd_name = 'settings'
|
|
||||||
case 'sc':
|
case 'sc':
|
||||||
cmd_name = 'scene'
|
cmd_name = 'scene'
|
||||||
case 'scc':
|
case 'scc':
|
||||||
@@ -44,6 +42,8 @@ class RootTyperAliasGroup(typer.core.TyperGroup):
|
|||||||
cmd_name = 'sceneitem'
|
cmd_name = 'sceneitem'
|
||||||
case 'ss':
|
case 'ss':
|
||||||
cmd_name = 'screenshot'
|
cmd_name = 'screenshot'
|
||||||
|
case 'set':
|
||||||
|
cmd_name = 'settings'
|
||||||
case 'st':
|
case 'st':
|
||||||
cmd_name = 'stream'
|
cmd_name = 'stream'
|
||||||
case 'sm':
|
case 'sm':
|
||||||
|
|||||||
@@ -23,11 +23,11 @@ for sub_typer in (
|
|||||||
'projector',
|
'projector',
|
||||||
'record',
|
'record',
|
||||||
'replaybuffer',
|
'replaybuffer',
|
||||||
'settings',
|
|
||||||
'scene',
|
'scene',
|
||||||
'scenecollection',
|
'scenecollection',
|
||||||
'sceneitem',
|
'sceneitem',
|
||||||
'screenshot',
|
'screenshot',
|
||||||
|
'settings',
|
||||||
'stream',
|
'stream',
|
||||||
'studiomode',
|
'studiomode',
|
||||||
'text',
|
'text',
|
||||||
|
|||||||
@@ -70,14 +70,14 @@ def list_(
|
|||||||
def current(
|
def current(
|
||||||
ctx: typer.Context,
|
ctx: typer.Context,
|
||||||
preview: Annotated[
|
preview: Annotated[
|
||||||
bool, typer.Option(help='Get the preview scene instead of the program scene')
|
bool,
|
||||||
|
typer.Option(
|
||||||
|
help='Get the preview scene instead of the program scene',
|
||||||
|
callback=validate.studio_mode_enabled,
|
||||||
|
),
|
||||||
] = False,
|
] = False,
|
||||||
):
|
):
|
||||||
"""Get the current program scene or preview scene."""
|
"""Get the current program scene or preview scene."""
|
||||||
if preview and not validate.studio_mode_enabled(ctx):
|
|
||||||
console.err.print('Studio mode is not enabled, cannot get preview scene.')
|
|
||||||
raise typer.Exit(1)
|
|
||||||
|
|
||||||
if preview:
|
if preview:
|
||||||
resp = ctx.obj['obsws'].get_current_preview_scene()
|
resp = ctx.obj['obsws'].get_current_preview_scene()
|
||||||
console.out.print(
|
console.out.print(
|
||||||
@@ -103,14 +103,13 @@ def switch(
|
|||||||
],
|
],
|
||||||
preview: Annotated[
|
preview: Annotated[
|
||||||
bool,
|
bool,
|
||||||
typer.Option(help='Switch to the preview scene instead of the program scene'),
|
typer.Option(
|
||||||
|
help='Switch to the preview scene instead of the program scene',
|
||||||
|
callback=validate.studio_mode_enabled,
|
||||||
|
),
|
||||||
] = False,
|
] = False,
|
||||||
):
|
):
|
||||||
"""Switch to a scene."""
|
"""Switch to a scene."""
|
||||||
if preview and not validate.studio_mode_enabled(ctx):
|
|
||||||
console.err.print('Studio mode is not enabled, cannot set the preview scene.')
|
|
||||||
raise typer.Exit(1)
|
|
||||||
|
|
||||||
if preview:
|
if preview:
|
||||||
ctx.obj['obsws'].set_current_preview_scene(scene_name)
|
ctx.obj['obsws'].set_current_preview_scene(scene_name)
|
||||||
console.out.print(
|
console.out.print(
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ from . import console
|
|||||||
skipped_option = typer.Option(parser=lambda _: _, hidden=True, expose_value=False)
|
skipped_option = typer.Option(parser=lambda _: _, hidden=True, expose_value=False)
|
||||||
|
|
||||||
|
|
||||||
def input_in_inputs(ctx: typer.Context, input_name: str) -> bool:
|
def input_in_inputs(ctx: typer.Context, input_name: str) -> str:
|
||||||
"""Ensure the given input exists in the list of inputs."""
|
"""Ensure the given input exists in the list of inputs."""
|
||||||
resp = ctx.obj['obsws'].get_input_list()
|
resp = ctx.obj['obsws'].get_input_list()
|
||||||
if not any(input.get('inputName') == input_name for input in resp.inputs):
|
if not any(input.get('inputName') == input_name for input in resp.inputs):
|
||||||
@@ -19,7 +19,7 @@ def input_in_inputs(ctx: typer.Context, input_name: str) -> bool:
|
|||||||
return input_name
|
return input_name
|
||||||
|
|
||||||
|
|
||||||
def input_not_in_inputs(ctx: typer.Context, input_name: str) -> bool:
|
def input_not_in_inputs(ctx: typer.Context, input_name: str) -> str:
|
||||||
"""Ensure an input does not already exist in the list of inputs."""
|
"""Ensure an input does not already exist in the list of inputs."""
|
||||||
resp = ctx.obj['obsws'].get_input_list()
|
resp = ctx.obj['obsws'].get_input_list()
|
||||||
if any(input.get('inputName') == input_name for input in resp.inputs):
|
if any(input.get('inputName') == input_name for input in resp.inputs):
|
||||||
@@ -31,7 +31,7 @@ def input_not_in_inputs(ctx: typer.Context, input_name: str) -> bool:
|
|||||||
def scene_in_scenes(ctx: typer.Context, scene_name: Optional[str]) -> str | None:
|
def scene_in_scenes(ctx: typer.Context, scene_name: Optional[str]) -> str | None:
|
||||||
"""Check if a scene exists in the list of scenes."""
|
"""Check if a scene exists in the list of scenes."""
|
||||||
if scene_name is None:
|
if scene_name is None:
|
||||||
return scene_name
|
return
|
||||||
|
|
||||||
resp = ctx.obj['obsws'].get_scene_list()
|
resp = ctx.obj['obsws'].get_scene_list()
|
||||||
if not any(scene.get('sceneName') == scene_name for scene in resp.scenes):
|
if not any(scene.get('sceneName') == scene_name for scene in resp.scenes):
|
||||||
@@ -40,10 +40,15 @@ def scene_in_scenes(ctx: typer.Context, scene_name: Optional[str]) -> str | None
|
|||||||
return scene_name
|
return scene_name
|
||||||
|
|
||||||
|
|
||||||
def studio_mode_enabled(ctx: typer.Context) -> bool:
|
def studio_mode_enabled(ctx: typer.Context, preview: bool) -> bool:
|
||||||
"""Check if studio mode is enabled."""
|
"""Ensure studio mode is enabled if preview option is used."""
|
||||||
resp = ctx.obj['obsws'].get_studio_mode_enabled()
|
resp = ctx.obj['obsws'].get_studio_mode_enabled()
|
||||||
return resp.studio_mode_enabled
|
if preview and not resp.studio_mode_enabled:
|
||||||
|
console.err.print(
|
||||||
|
'Studio mode is disabled. This action requires it to be enabled.'
|
||||||
|
)
|
||||||
|
raise typer.Exit(1)
|
||||||
|
return preview
|
||||||
|
|
||||||
|
|
||||||
def scene_collection_in_scene_collections(
|
def scene_collection_in_scene_collections(
|
||||||
@@ -114,7 +119,7 @@ def kind_in_input_kinds(ctx: typer.Context, input_kind: str) -> str:
|
|||||||
def timecode_format(ctx: typer.Context, timecode: Optional[str]) -> str | None:
|
def timecode_format(ctx: typer.Context, timecode: Optional[str]) -> str | None:
|
||||||
"""Validate that a timecode is in HH:MM:SS or MM:SS format."""
|
"""Validate that a timecode is in HH:MM:SS or MM:SS format."""
|
||||||
if timecode is None:
|
if timecode is None:
|
||||||
return timecode
|
return
|
||||||
|
|
||||||
match timecode.split(':'):
|
match timecode.split(':'):
|
||||||
case [mm, ss]:
|
case [mm, ss]:
|
||||||
|
|||||||
Reference in New Issue
Block a user