mirror of
https://github.com/onyx-and-iris/slobs-cli.git
synced 2025-06-27 15:20:24 +01:00
add --preview option to scene switch command
patch bump
This commit is contained in:
parent
14f89dd636
commit
560b88e949
2
.gitignore
vendored
2
.gitignore
vendored
@ -160,3 +160,5 @@ cython_debug/
|
|||||||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||||
#.idea/
|
#.idea/
|
||||||
|
|
||||||
|
test-*.py
|
@ -1,6 +1,6 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "slobs-cli"
|
name = "slobs-cli"
|
||||||
version = "0.7.0"
|
version = "0.7.1"
|
||||||
description = "A command line application for Streamlabs Desktop"
|
description = "A command line application for Streamlabs Desktop"
|
||||||
authors = [{ name = "onyx-and-iris", email = "code@onyxandiris.online" }]
|
authors = [{ name = "onyx-and-iris", email = "code@onyxandiris.online" }]
|
||||||
dependencies = ["pyslobs>=2.0.4", "asyncclick>=8.1.8"]
|
dependencies = ["pyslobs>=2.0.4", "asyncclick>=8.1.8"]
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import asyncclick as click
|
import asyncclick as click
|
||||||
from anyio import create_task_group
|
from anyio import create_task_group
|
||||||
from pyslobs import ScenesService
|
from pyslobs import ScenesService, TransitionsService
|
||||||
|
|
||||||
from .cli import cli
|
from .cli import cli
|
||||||
|
|
||||||
@ -60,26 +60,57 @@ async def current(ctx: click.Context):
|
|||||||
|
|
||||||
@scene.command()
|
@scene.command()
|
||||||
@click.argument("scene_name", type=str)
|
@click.argument("scene_name", type=str)
|
||||||
|
@click.option(
|
||||||
|
"--preview",
|
||||||
|
is_flag=True,
|
||||||
|
help="Switch the preview scene only.",
|
||||||
|
)
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
async def switch(ctx: click.Context, scene_name: str):
|
async def switch(ctx: click.Context, scene_name: str, preview: bool = False):
|
||||||
"""Switch to a scene by its name."""
|
"""Switch to a scene by its name."""
|
||||||
|
|
||||||
conn = ctx.obj["connection"]
|
conn = ctx.obj["connection"]
|
||||||
ss = ScenesService(conn)
|
ss = ScenesService(conn)
|
||||||
|
ts = TransitionsService(conn)
|
||||||
|
|
||||||
async def _run():
|
async def _run():
|
||||||
scenes = await ss.get_scenes()
|
scenes = await ss.get_scenes()
|
||||||
for scene in scenes:
|
for scene in scenes:
|
||||||
if scene.name == scene_name:
|
if scene.name == scene_name:
|
||||||
await ss.make_scene_active(scene.id)
|
current_state = await ts.get_model()
|
||||||
click.echo(f"Switched to scene: {click.style(scene.name, fg='green')}")
|
|
||||||
conn.close()
|
if current_state.studio_mode:
|
||||||
|
await ss.make_scene_active(scene.id)
|
||||||
|
if preview:
|
||||||
|
click.echo(
|
||||||
|
f"Switched to scene: {click.style(scene.name, fg='blue')} (ID: {scene.id}) in preview mode."
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
await ts.execute_studio_mode_transition()
|
||||||
|
click.echo(
|
||||||
|
f"Switched to scene: {click.style(scene.name, fg='blue')} (ID: {scene.id}) in active mode."
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
if preview:
|
||||||
|
conn.close()
|
||||||
|
raise click.Abort(
|
||||||
|
click.style(
|
||||||
|
"Cannot switch to preview scene in non-studio mode.",
|
||||||
|
fg="red",
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
await ss.make_scene_active(scene.id)
|
||||||
|
click.echo(
|
||||||
|
f"Switched to scene: {click.style(scene.name, fg='blue')} (ID: {scene.id}) in active mode."
|
||||||
|
)
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
conn.close()
|
conn.close()
|
||||||
raise click.ClickException(
|
raise click.ClickException(
|
||||||
click.style(f"Scene '{scene_name}' not found.", fg="red")
|
click.style(f"Scene '{scene_name}' not found.", fg="red")
|
||||||
)
|
)
|
||||||
|
conn.close()
|
||||||
|
|
||||||
async with create_task_group() as tg:
|
async with create_task_group() as tg:
|
||||||
tg.start_soon(conn.background_processing)
|
tg.start_soon(conn.background_processing)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user