From 76d5e8233fdaf4033bcf1cef99a8ccc24d131d38 Mon Sep 17 00:00:00 2001 From: Nick Mowen Date: Tue, 15 Feb 2022 21:55:38 -0700 Subject: [PATCH] Properly support any label --- frigate/http.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/frigate/http.py b/frigate/http.py index cc1b4bfa9..039942f7a 100644 --- a/frigate/http.py +++ b/frigate/http.py @@ -357,20 +357,21 @@ def stats(): def latest(camera_name, label): png_bytes = None if camera_name in current_app.frigate_config.cameras: - - if label == "any": - label = "*" - - event = ( + event_query = ( Event.select() .where(Event.camera == camera_name) - .where(Event.label == label) .where(Event.has_snapshot == True) .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 with open( os.path.join(CLIPS_DIR, f"{event.camera}-{event.id}-clean.png"), "rb"