mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-04-09 16:47:37 +03:00
remove dead code and repair utf-8 preset names via latin-1 round trip (#22818)
Some checks are pending
CI / AMD64 Build (push) Waiting to run
CI / ARM Build (push) Waiting to run
CI / Jetson Jetpack 6 (push) Waiting to run
CI / AMD64 Extra Build (push) Blocked by required conditions
CI / ARM Extra Build (push) Blocked by required conditions
CI / Synaptics Build (push) Blocked by required conditions
CI / Assemble and push default build (push) Blocked by required conditions
Some checks are pending
CI / AMD64 Build (push) Waiting to run
CI / ARM Build (push) Waiting to run
CI / Jetson Jetpack 6 (push) Waiting to run
CI / AMD64 Extra Build (push) Blocked by required conditions
CI / ARM Extra Build (push) Blocked by required conditions
CI / Synaptics Build (push) Blocked by required conditions
CI / Assemble and push default build (push) Blocked by required conditions
This commit is contained in:
parent
8f13932c64
commit
556d5d8c9d
@ -152,21 +152,12 @@ class OnvifController:
|
|||||||
|
|
||||||
cam = self.camera_configs[cam_name]
|
cam = self.camera_configs[cam_name]
|
||||||
try:
|
try:
|
||||||
user = cam.onvif.user
|
|
||||||
password = cam.onvif.password
|
|
||||||
|
|
||||||
if user is not None and isinstance(user, bytes):
|
|
||||||
user = user.decode("utf-8")
|
|
||||||
|
|
||||||
if password is not None and isinstance(password, bytes):
|
|
||||||
password = password.decode("utf-8")
|
|
||||||
|
|
||||||
self.cams[cam_name] = {
|
self.cams[cam_name] = {
|
||||||
"onvif": ONVIFCamera(
|
"onvif": ONVIFCamera(
|
||||||
cam.onvif.host,
|
cam.onvif.host,
|
||||||
cam.onvif.port,
|
cam.onvif.port,
|
||||||
user,
|
cam.onvif.user,
|
||||||
password,
|
cam.onvif.password,
|
||||||
wsdl_dir=str(Path(find_spec("onvif").origin).parent / "wsdl"),
|
wsdl_dir=str(Path(find_spec("onvif").origin).parent / "wsdl"),
|
||||||
adjust_time=cam.onvif.ignore_time_mismatch,
|
adjust_time=cam.onvif.ignore_time_mismatch,
|
||||||
encrypt=not cam.onvif.tls_insecure,
|
encrypt=not cam.onvif.tls_insecure,
|
||||||
@ -459,15 +450,15 @@ class OnvifController:
|
|||||||
presets = []
|
presets = []
|
||||||
|
|
||||||
for preset in presets:
|
for preset in presets:
|
||||||
# Ensure preset name is a Unicode string and handle UTF-8 characters correctly
|
|
||||||
preset_name = getattr(preset, "Name") or f"preset {preset['token']}"
|
preset_name = getattr(preset, "Name") or f"preset {preset['token']}"
|
||||||
|
# Some cameras (e.g. Reolink) return UTF-8 bytes that zeep decodes
|
||||||
if isinstance(preset_name, bytes):
|
# as latin-1, producing mojibake. Detect that and repair it by
|
||||||
preset_name = preset_name.decode("utf-8")
|
# round-tripping through latin-1 -> utf-8.
|
||||||
|
try:
|
||||||
# Convert to lowercase while preserving UTF-8 characters
|
preset_name = preset_name.encode("latin-1").decode("utf-8")
|
||||||
preset_name_lower = preset_name.lower()
|
except (UnicodeEncodeError, UnicodeDecodeError):
|
||||||
self.cams[camera_name]["presets"][preset_name_lower] = preset["token"]
|
pass
|
||||||
|
self.cams[camera_name]["presets"][preset_name.lower()] = preset["token"]
|
||||||
|
|
||||||
# get list of supported features
|
# get list of supported features
|
||||||
supported_features = []
|
supported_features = []
|
||||||
@ -695,9 +686,6 @@ class OnvifController:
|
|||||||
self.cams[camera_name]["active"] = False
|
self.cams[camera_name]["active"] = False
|
||||||
|
|
||||||
async def _move_to_preset(self, camera_name: str, preset: str) -> None:
|
async def _move_to_preset(self, camera_name: str, preset: str) -> None:
|
||||||
if isinstance(preset, bytes):
|
|
||||||
preset = preset.decode("utf-8")
|
|
||||||
|
|
||||||
preset = preset.lower()
|
preset = preset.lower()
|
||||||
|
|
||||||
if preset not in self.cams[camera_name]["presets"]:
|
if preset not in self.cams[camera_name]["presets"]:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user