feat(snot): add search history and purge command

This commit is contained in:
abdus committed 2026-10-28 08:37:23 +00:00
1 parent afdb0ac636
commit 7e8541d5d7
2 files changed
+87 -2

No files matched your search

+15 -1
View File
@@ -31,9 +31,10 @@ import click
import httpx
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s: %(message)s")
logging.getLogger("httpx").setLevel(logging.WARNING)
HandlerFunc = Callable[["Request"], "Response"]
client = httpx.Client(base_url="http://klein:18543", timeout=30)
client = httpx.Client(base_url="http://klein.talpa-carat.ts.net:18543", timeout=30)
@dataclasses.dataclass
@@ -747,6 +748,19 @@ def scan(paths: list[Path]):
scan_videos(video_paths=list(paths))
@cli.command()
def purge() -> None:
"""Remove box entries not seen in the last 24 hours."""
cutoff = datetime.datetime.now(datetime.timezone.utc) - datetime.timedelta(hours=24)
response = client.delete(
"/videos",
params={"category": "eq.box", "last_seen_at": f"lt.{cutoff.isoformat()}"},
headers={"Prefer": "return=representation"},
)
response.raise_for_status()
logging.info(f"Purged {len(response.json())} box entries")
@cli.command("mark-deletion")
@click.argument("paths", nargs=-1, type=Path)
def mark_deletion(paths: list[Path]):