mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-02 17:25:22 +03:00
Properly support any label
This commit is contained in:
parent
cc4d48a6ef
commit
76d5e8233f
@ -357,20 +357,21 @@ def stats():
|
|||||||
def latest(camera_name, label):
|
def latest(camera_name, label):
|
||||||
png_bytes = None
|
png_bytes = None
|
||||||
if camera_name in current_app.frigate_config.cameras:
|
if camera_name in current_app.frigate_config.cameras:
|
||||||
|
event_query = (
|
||||||
if label == "any":
|
|
||||||
label = "*"
|
|
||||||
|
|
||||||
event = (
|
|
||||||
Event.select()
|
Event.select()
|
||||||
.where(Event.camera == camera_name)
|
.where(Event.camera == camera_name)
|
||||||
.where(Event.label == label)
|
|
||||||
.where(Event.has_snapshot == True)
|
.where(Event.has_snapshot == True)
|
||||||
.where(Event.end_time != None)
|
.where(Event.end_time != None)
|
||||||
.order_by(Event.start_time.desc())
|
|
||||||
.get()
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if label != "any":
|
||||||
|
event_query.where(Event.label == label)
|
||||||
|
|
||||||
|
event = event_query.order_by(Event.start_time.desc()).get()
|
||||||
|
|
||||||
|
if event is None:
|
||||||
|
return "No event for {} was found".format(label), 404
|
||||||
|
|
||||||
# read snapshot from disk
|
# read snapshot from disk
|
||||||
with open(
|
with open(
|
||||||
os.path.join(CLIPS_DIR, f"{event.camera}-{event.id}-clean.png"), "rb"
|
os.path.join(CLIPS_DIR, f"{event.camera}-{event.id}-clean.png"), "rb"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user