chore(core): validate clip configuration

This commit is contained in:
2026-04-26 23:54:41 +01:00
parent b3c38c18e0
commit 974251d1db
2 changed files with 7 additions and 4 deletions

View File

@@ -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",

View File

@@ -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