From e7d9deba7157a2b2dfcca1c33519dbdc80100b99 Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Tue, 27 May 2025 01:20:35 +0100 Subject: [PATCH] record stop now prints the the output path of the recording added record directory command record unit test updated README updated minor bump --- README.md | 13 +++++++++++++ obsws_cli/__about__.py | 2 +- obsws_cli/record.py | 31 +++++++++++++++++++++++++++++-- tests/test_record.py | 2 +- 4 files changed, 44 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d57fbcd..4865e84 100644 --- a/README.md +++ b/README.md @@ -324,6 +324,19 @@ obsws-cli record resume obsws-cli record pause ``` +- directory: Get or set the recording directory. + + *optional* + - args: + - if not passed the current record directory will be printed. + +```console +obsws-cli record directory + +obsws-cli record directory "/home/me/obs-vids/" +obsws-cli record directory "C:/Users/me/Videos" +``` + #### Stream - start: Start streaming. diff --git a/obsws_cli/__about__.py b/obsws_cli/__about__.py index 03a7141..7c80f89 100644 --- a/obsws_cli/__about__.py +++ b/obsws_cli/__about__.py @@ -1,4 +1,4 @@ # SPDX-FileCopyrightText: 2025-present onyx-and-iris # # SPDX-License-Identifier: MIT -__version__ = "0.13.3" +__version__ = "0.14.0" diff --git a/obsws_cli/record.py b/obsws_cli/record.py index 2f318ce..a0e0737 100644 --- a/obsws_cli/record.py +++ b/obsws_cli/record.py @@ -1,5 +1,8 @@ """module for controlling OBS recording functionality.""" +from pathlib import Path +from typing import Annotated, Optional + import typer from rich.console import Console @@ -45,8 +48,8 @@ def stop(ctx: typer.Context): err_console.print('Recording is not in progress, cannot stop.') raise typer.Exit(1) - ctx.obj.stop_record() - out_console.print('Recording stopped successfully.') + resp = ctx.obj.stop_record() + out_console.print(f'Recording stopped successfully. Saved to: {resp.output_path}') @app.command('toggle | tg') @@ -100,3 +103,27 @@ def pause(ctx: typer.Context): ctx.obj.pause_record() out_console.print('Recording paused successfully.') + + +@app.command('directory | d') +def directory( + ctx: typer.Context, + record_directory: Annotated[ + Optional[Path], + # Since the CLI and OBS may be running on different platforms, + # we won't validate the path here. + typer.Argument( + file_okay=False, + dir_okay=True, + help='Directory to set for recording.', + ), + ] = None, +): + """Get or set the recording directory.""" + if record_directory is not None: + ctx.obj.set_record_directory(str(record_directory)) + out_console.print(f'Recording directory updated to: {record_directory}') + else: + out_console.print( + f'Recording directory: {ctx.obj.get_record_directory().record_directory}' + ) diff --git a/tests/test_record.py b/tests/test_record.py index c4ca8e3..ffae02a 100644 --- a/tests/test_record.py +++ b/tests/test_record.py @@ -23,7 +23,7 @@ def test_record_start_status_stop(): result = runner.invoke(app, ['record', 'stop']) assert result.exit_code == 0 - assert 'Recording stopped successfully.' in result.stdout + assert 'Recording stopped successfully. Saved to:' in result.stdout time.sleep(0.5) # Wait for the recording to stop