mirror of
https://github.com/onyx-and-iris/slobs-cli.git
synced 2025-06-27 15:20:24 +01:00
implement record command group
minor bump
This commit is contained in:
parent
7227183073
commit
dcd34b0213
@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "slobs-cli"
|
||||
version = "0.3.1"
|
||||
version = "0.4.0"
|
||||
description = "A command line application for Streamlabs Desktop"
|
||||
authors = [{ name = "onyx-and-iris", email = "code@onyxandiris.online" }]
|
||||
dependencies = ["pyslobs>=2.0.4", "asyncclick>=8.1.8"]
|
||||
|
@ -1,5 +1,6 @@
|
||||
from .cli import cli
|
||||
from .record import record
|
||||
from .scene import scene
|
||||
from .stream import stream
|
||||
|
||||
__all__ = ["cli", "scene", "stream"]
|
||||
__all__ = ["cli", "scene", "stream", "record"]
|
||||
|
112
src/slobs_cli/record.py
Normal file
112
src/slobs_cli/record.py
Normal file
@ -0,0 +1,112 @@
|
||||
import asyncclick as click
|
||||
from anyio import create_task_group
|
||||
from pyslobs import StreamingService
|
||||
|
||||
from .cli import cli
|
||||
|
||||
|
||||
@cli.group()
|
||||
def record():
|
||||
"""Recording management commands."""
|
||||
|
||||
|
||||
@record.command()
|
||||
@click.pass_context
|
||||
async def start(ctx: click.Context):
|
||||
"""Start recording."""
|
||||
|
||||
conn = ctx.obj["connection"]
|
||||
ss = StreamingService(conn)
|
||||
|
||||
async def _run():
|
||||
current_state = await ss.get_model()
|
||||
active = current_state.recording_status != "offline"
|
||||
|
||||
if active:
|
||||
conn.close()
|
||||
raise click.Abort(click.style("Recording is already active.", fg="red"))
|
||||
|
||||
await ss.toggle_recording()
|
||||
click.echo("Recording started.")
|
||||
|
||||
conn.close()
|
||||
|
||||
async with create_task_group() as tg:
|
||||
tg.start_soon(conn.background_processing)
|
||||
tg.start_soon(_run)
|
||||
|
||||
|
||||
@record.command()
|
||||
@click.pass_context
|
||||
async def stop(ctx: click.Context):
|
||||
"""Stop recording."""
|
||||
|
||||
conn = ctx.obj["connection"]
|
||||
ss = StreamingService(conn)
|
||||
|
||||
async def _run():
|
||||
current_state = await ss.get_model()
|
||||
active = current_state.recording_status != "offline"
|
||||
|
||||
if not active:
|
||||
conn.close()
|
||||
raise click.Abort(click.style("Recording is already inactive.", fg="red"))
|
||||
|
||||
await ss.toggle_recording()
|
||||
click.echo("Recording stopped.")
|
||||
|
||||
conn.close()
|
||||
|
||||
async with create_task_group() as tg:
|
||||
tg.start_soon(conn.background_processing)
|
||||
tg.start_soon(_run)
|
||||
|
||||
|
||||
@record.command()
|
||||
@click.pass_context
|
||||
async def status(ctx: click.Context):
|
||||
"""Get recording status."""
|
||||
|
||||
conn = ctx.obj["connection"]
|
||||
ss = StreamingService(conn)
|
||||
|
||||
async def _run():
|
||||
current_state = await ss.get_model()
|
||||
active = current_state.recording_status != "offline"
|
||||
|
||||
if active:
|
||||
click.echo("Recording is currently active.")
|
||||
else:
|
||||
click.echo("Recording is currently inactive.")
|
||||
|
||||
conn.close()
|
||||
|
||||
async with create_task_group() as tg:
|
||||
tg.start_soon(conn.background_processing)
|
||||
tg.start_soon(_run)
|
||||
|
||||
|
||||
@record.command()
|
||||
@click.pass_context
|
||||
async def toggle(ctx: click.Context):
|
||||
"""Toggle recording status."""
|
||||
|
||||
conn = ctx.obj["connection"]
|
||||
ss = StreamingService(conn)
|
||||
|
||||
async def _run():
|
||||
current_state = await ss.get_model()
|
||||
active = current_state.recording_status != "offline"
|
||||
|
||||
if active:
|
||||
await ss.toggle_recording()
|
||||
click.echo("Recording stopped.")
|
||||
else:
|
||||
await ss.toggle_recording()
|
||||
click.echo("Recording started.")
|
||||
|
||||
conn.close()
|
||||
|
||||
async with create_task_group() as tg:
|
||||
tg.start_soon(conn.background_processing)
|
||||
tg.start_soon(_run)
|
Loading…
x
Reference in New Issue
Block a user