Remove obsolete event clip logic (#16504)

* Remove obsolete event clip logic

* Formatting
This commit is contained in:
Nicolas Mowen 2025-02-11 14:16:10 -07:00 committed by GitHub
parent 2458f667c4
commit 73fee6372b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1088,30 +1088,8 @@ def event_clip(request: Request, event_id: str):
content={"success": False, "message": "Clip not available"}, status_code=404
)
file_name = f"{event.camera}-{event.id}.mp4"
clip_path = os.path.join(CLIPS_DIR, file_name)
if not os.path.isfile(clip_path):
end_ts = (
datetime.now().timestamp() if event.end_time is None else event.end_time
)
return recording_clip(request, event.camera, event.start_time, end_ts)
headers = {
"Content-Description": "File Transfer",
"Cache-Control": "no-cache",
"Content-Type": "video/mp4",
"Content-Length": str(os.path.getsize(clip_path)),
# nginx: https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_ignore_headers
"X-Accel-Redirect": f"/clips/{file_name}",
}
return FileResponse(
clip_path,
media_type="video/mp4",
filename=file_name,
headers=headers,
)
end_ts = datetime.now().timestamp() if event.end_time is None else event.end_time
return recording_clip(request, event.camera, event.start_time, end_ts)
@router.get("/events/{event_id}/preview.gif")