use titlecase for better python capitalization

the built in .title() method isn't great because it capitalizes letters after apostrophes, so it would look like "Josh'S"
This commit is contained in:
Josh Hawkins 2025-05-17 11:39:18 -05:00
parent 2a6c73d35f
commit 6b3e074785
3 changed files with 5 additions and 2 deletions

View File

@ -264,6 +264,7 @@ tensorrt
tflite
thresholded
timelapse
titlecase
tmpfs
tobytes
toggleable

View File

@ -31,6 +31,7 @@ norfair == 2.2.*
setproctitle == 1.3.*
ws4py == 0.5.*
unidecode == 1.3.*
titlecase == 2.4.*
# Image Manipulation
numpy == 1.26.*
opencv-python-headless == 4.11.0.*

View File

@ -12,6 +12,7 @@ from typing import Any, Callable
from py_vapid import Vapid01
from pywebpush import WebPusher
from titlecase import titlecase
from frigate.comms.base_communicator import Communicator
from frigate.comms.config_updater import ConfigSubscriber
@ -325,8 +326,8 @@ class WebPushClient(Communicator): # type: ignore[misc]
sorted_objects.update(payload["after"]["data"]["sub_labels"])
title = f"{', '.join(sorted_objects).replace('_', ' ').title()}{' was' if state == 'end' else ''} detected in {', '.join(payload['after']['data']['zones']).replace('_', ' ').title()}"
message = f"Detected on {camera.replace('_', ' ').title()}"
title = f"{titlecase(', '.join(sorted_objects).replace('_', ' '))}{' was' if state == 'end' else ''} detected in {titlecase(', '.join(payload['after']['data']['zones']).replace('_', ' '))}"
message = f"Detected on {titlecase(camera.replace('_', ' '))}"
image = f"{payload['after']['thumb_path'].replace('/media/frigate', '')}"
# if event is ongoing open to live view otherwise open to recordings view