mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-11 13:45:25 +03:00
Safely load config file for go2rtc
This commit is contained in:
parent
9652ea9e96
commit
2802a484a2
@ -32,6 +32,7 @@ config_file_yaml = config_file.replace(".yml", ".yaml")
|
|||||||
if os.path.isfile(config_file_yaml):
|
if os.path.isfile(config_file_yaml):
|
||||||
config_file = config_file_yaml
|
config_file = config_file_yaml
|
||||||
|
|
||||||
|
try:
|
||||||
with open(config_file) as f:
|
with open(config_file) as f:
|
||||||
raw_config = f.read()
|
raw_config = f.read()
|
||||||
|
|
||||||
@ -39,6 +40,8 @@ if config_file.endswith((".yaml", ".yml")):
|
|||||||
config: dict[str, any] = yaml.safe_load(raw_config)
|
config: dict[str, any] = yaml.safe_load(raw_config)
|
||||||
elif config_file.endswith(".json"):
|
elif config_file.endswith(".json"):
|
||||||
config: dict[str, any] = json.loads(raw_config)
|
config: dict[str, any] = json.loads(raw_config)
|
||||||
|
except FileNotFoundError:
|
||||||
|
config: dict[str, any] = {}
|
||||||
|
|
||||||
go2rtc_config: dict[str, any] = config.get("go2rtc", {})
|
go2rtc_config: dict[str, any] = config.get("go2rtc", {})
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user