chore(core): validate clip configuration
This commit is contained in:
@@ -42,7 +42,7 @@ def build_mark_parser(subparsers: argparse._SubParsersAction) -> None:
|
|||||||
def build_list_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")
|
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(
|
subparsers.add_parser(
|
||||||
"install",
|
"install",
|
||||||
help="Enable background recording daemon",
|
help="Enable background recording daemon",
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ from rewind.paths import load_config
|
|||||||
from tqdm import tqdm
|
from tqdm import tqdm
|
||||||
|
|
||||||
def clip(seconds_from_end: float) -> None:
|
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"])
|
clip_output = os.path.expanduser(load_config()["record"]["clip_output"])
|
||||||
os.makedirs(clip_output, exist_ok=True)
|
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)
|
first_timestamp = get_marker_timestamp(first_marker)
|
||||||
second_timestamp = get_marker_timestamp(second_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:
|
if first_timestamp >= second_timestamp:
|
||||||
raise ValueError("First marker must be before second marker")
|
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(
|
files, start_offset, end_offset = _get_ts_files(
|
||||||
first_timestamp,
|
first_timestamp,
|
||||||
second_timestamp
|
second_timestamp
|
||||||
|
|||||||
Reference in New Issue
Block a user