Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Endpoint for last clip #9710

Merged
merged 7 commits into from
Mar 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/docs/integrations/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,10 @@ Returns a thumbnail for the event id optimized for notifications. Works while th

Returns the thumbnail from the latest event for the given camera and label combo. Using `any` as the label will return the latest thumbnail regardless of type.

### `GET /api/<camera_name>/<label>/clip.mp4`

Returns the clip from the latest event for the given camera and label combo. Using `any` as the label will return the latest clip regardless of type.

### `GET /api/events/<id>/clip.mp4`

Returns the clip for the event id. Works after the event has ended.
Expand Down
19 changes: 19 additions & 0 deletions frigate/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,25 @@ def label_thumbnail(camera_name, label):
return response


@bp.route("/<camera_name>/<label>/clip.mp4")
def label_clip(camera_name, label):
label = unquote(label)
event_query = Event.select(fn.MAX(Event.id)).where(
Event.camera == camera_name, Event.has_clip == True
)
if label != "any":
event_query = event_query.where(Event.label == label)

try:
event = event_query.get()

return event_clip(event)
except DoesNotExist:
return make_response(
jsonify({"success": False, "message": "Event not found"}), 404
)


@bp.route("/events/<id>/snapshot.jpg")
def event_snapshot(id):
download = request.args.get("download", type=bool)
Expand Down