Skip to content

Commit

Permalink
Don't use preprocessor
Browse files Browse the repository at this point in the history
  • Loading branch information
uvjustin committed Aug 19, 2022
1 parent 0bcfbc9 commit 466f8b6
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions frigate/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
Flask,
Response,
current_app,
g,
jsonify,
make_response,
request,
Expand All @@ -37,11 +36,6 @@
bp = Blueprint("frigate", __name__)


@bp.url_value_preprocessor
def unquote_label(endpoint, values):
g.label = unquote(values.pop("label", ""))


def create_app(
frigate_config,
database: SqliteDatabase,
Expand Down Expand Up @@ -347,8 +341,9 @@ def event_thumbnail(id, max_cache_age=2592000):

@bp.route("/<camera_name>/<label>/best.jpg")
@bp.route("/<camera_name>/<label>/thumbnail.jpg")
def label_thumbnail(camera_name):
if g.label == "any":
def label_thumbnail(camera_name, label):
label = unquote(label)
if label == "any":
event_query = (
Event.select()
.where(Event.camera == camera_name)
Expand All @@ -359,7 +354,7 @@ def label_thumbnail(camera_name):
event_query = (
Event.select()
.where(Event.camera == camera_name)
.where(Event.label == g.label)
.where(Event.label == label)
.where(Event.has_snapshot == True)
.order_by(Event.start_time.desc())
)
Expand Down Expand Up @@ -430,8 +425,9 @@ def event_snapshot(id):


@bp.route("/<camera_name>/<label>/snapshot.jpg")
def label_snapshot(camera_name):
if g.label == "any":
def label_snapshot(camera_name, label):
label = unquote(label)
if label == "any":
event_query = (
Event.select()
.where(Event.camera == camera_name)
Expand All @@ -442,7 +438,7 @@ def label_snapshot(camera_name):
event_query = (
Event.select()
.where(Event.camera == camera_name)
.where(Event.label == g.label)
.where(Event.label == label)
.where(Event.has_snapshot == True)
.order_by(Event.start_time.desc())
)
Expand Down

0 comments on commit 466f8b6

Please sign in to comment.