diff --git a/rewind/cli.py b/rewind/cli.py index 3a42995..795b501 100755 --- a/rewind/cli.py +++ b/rewind/cli.py @@ -42,7 +42,7 @@ def build_mark_parser(subparsers: argparse._SubParsersAction) -> None: def build_list_parser(subparsers: argparse._SubParsersAction) -> None: list_parser = subparsers.add_parser("list", help="List all markers in the recording") -def build_install_parser(subparsers: argparse._SubParsersAction): +def build_install_parser(subparsers: argparse._SubParsersAction) -> None: subparsers.add_parser( "install", help="Enable background recording daemon", diff --git a/rewind/core.py b/rewind/core.py index 78a53d0..faf196b 100644 --- a/rewind/core.py +++ b/rewind/core.py @@ -8,6 +8,9 @@ from rewind.paths import load_config from tqdm import tqdm def clip(seconds_from_end: float) -> None: + if seconds_from_end <= 0 or seconds_from_end > 600: + raise ValueError("Clip length must be positive and less than or equal to 10 minutes") + clip_output = os.path.expanduser(load_config()["record"]["clip_output"]) os.makedirs(clip_output, exist_ok=True) @@ -33,12 +36,12 @@ def save(first_marker: str, second_marker: str): first_timestamp = get_marker_timestamp(first_marker) second_timestamp = get_marker_timestamp(second_marker) - output_file_name = f"{datetime.datetime.fromtimestamp(first_timestamp).strftime('%Y-%m-%d_%H:%M:%S')}-[{first_marker}-{second_marker}].mp4" - output_path = os.path.join(vod_dir, output_file_name) - if first_timestamp >= second_timestamp: raise ValueError("First marker must be before second marker") + output_file_name = f"{datetime.datetime.fromtimestamp(first_timestamp).strftime('%Y-%m-%d_%H:%M:%S')}-[{first_marker}-{second_marker}].mp4" + output_path = os.path.join(vod_dir, output_file_name) + files, start_offset, end_offset = _get_ts_files( first_timestamp, second_timestamp