import time
import requests
BASE = "https://trio.machinefi.com/api"
HEADERS = {"Authorization": "Bearer YOUR_API_KEY", "Content-Type": "application/json"}
start = requests.post(
f"{BASE}/live-monitor",
headers=HEADERS,
json={
"stream_url": "https://www.youtube.com/watch?v=jfKfPfyJRdk",
"condition": "Is there a cat visible?"
},
timeout=30,
)
start.raise_for_status()
job_id = start.json()["job_id"]
while True:
status_resp = requests.get(f"{BASE}/jobs/{job_id}", headers=HEADERS, timeout=30)
status_resp.raise_for_status()
job = status_resp.json()
status = job["status"]
if status in ("completed", "stopped", "failed"):
print(f"Terminal status: {status}")
print(job.get("stats", {}))
break
time.sleep(5)