diff --git a/frigate/config.py b/frigate/config.py index 39fa60224..ef88d7acb 100644 --- a/frigate/config.py +++ b/frigate/config.py @@ -12,7 +12,7 @@ import yaml from pydantic import BaseModel, Extra, Field, validator from pydantic.fields import PrivateAttr -from frigate.const import BASE_DIR, CACHE_DIR, YAML_EXT +from frigate.const import BASE_DIR, CACHE_DIR, REGEX_CAMERA_NAME, YAML_EXT from frigate.util import create_mask, deep_merge, load_labels logger = logging.getLogger(__name__) @@ -540,7 +540,7 @@ class CameraUiConfig(FrigateBaseModel): class CameraConfig(FrigateBaseModel): - name: Optional[str] = Field(title="Camera name.", regex="^[a-zA-Z0-9_-]+$") + name: Optional[str] = Field(title="Camera name.", regex=REGEX_CAMERA_NAME) enabled: bool = Field(default=True, title="Enable camera.") ffmpeg: CameraFfmpegConfig = Field(title="FFmpeg configuration for the camera.") best_image_timeout: int = Field( diff --git a/frigate/const.py b/frigate/const.py index 004e3c28e..d339379bf 100644 --- a/frigate/const.py +++ b/frigate/const.py @@ -5,3 +5,8 @@ CACHE_DIR = "/tmp/cache" YAML_EXT = (".yaml", ".yml") PLUS_ENV_VAR = "PLUS_API_KEY" PLUS_API_HOST = "https://api.frigate.video" + +# Regex Consts + +REGEX_CAMERA_NAME = "^[a-zA-Z0-9_-]+$" +REGEX_CAMERA_USER_PASS = ""