From 4118590dc7486f07acb333b3b6585fa5c49e1c76 Mon Sep 17 00:00:00 2001 From: Dylan De Faoite Date: Thu, 18 Dec 2025 20:30:39 +0000 Subject: [PATCH] UPDATE core.py and daemon.py to use max_record_time from config for managing old markers --- rewind/core.py | 9 ++++++--- rewind/daemon.py | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/rewind/core.py b/rewind/core.py index 04933ed..702bbc4 100644 --- a/rewind/core.py +++ b/rewind/core.py @@ -3,7 +3,8 @@ import os import datetime import subprocess import json -from rewind.paths import load_state + +from rewind.paths import load_state, load_config """ Retrieves .ts files recorded between the specified timestamps. @@ -85,6 +86,8 @@ def mark(name: str) -> None: print(f"Added marker: {name}") def print_markers() -> None: + clean_old_markers(load_config()["record"]["max_record_time"]) + markers_file = os.path.join(os.path.dirname(__file__), "markers.json") if not os.path.exists(markers_file): print("No markers found.") @@ -97,7 +100,7 @@ def print_markers() -> None: format_time = datetime.datetime.fromtimestamp(marker['timestamp']).strftime('%Y-%m-%d %H:%M:%S') print(f"{format_time} -> {marker['name']}") -def clean_old_markers() -> None: +def clean_old_markers(max_age_seconds: float) -> None: markers_file = os.path.join(os.path.dirname(__file__), "markers.json") if not os.path.exists(markers_file): return @@ -106,7 +109,7 @@ def clean_old_markers() -> None: markers = json.load(f) current_time = datetime.datetime.now().timestamp() - markers = [m for m in markers if current_time - m['timestamp'] <= 60] + markers = [m for m in markers if current_time - m['timestamp'] <= max_age_seconds] with open(markers_file, "w") as f: json.dump(markers, f, indent=4) diff --git a/rewind/daemon.py b/rewind/daemon.py index 112ab45..1f60e79 100755 --- a/rewind/daemon.py +++ b/rewind/daemon.py @@ -100,7 +100,7 @@ def main() -> None: observer.start() while running: - cleanup_old_files(recording_dir, MAX_AGE_SECONDS) + cleanup_old_files(recording_dir, config["record"]["max_record_time"]) time.sleep(INTERVAL) finally: stop_recording(con)