-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
24 lines (21 loc) · 826 Bytes
/
config.py
File metadata and controls
24 lines (21 loc) · 826 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import yaml
import os
# Loads and provides dictionary access to the config
with open("config.yaml", 'r') as stream:
dvrConfig = yaml.safe_load(stream)
environKeys = ["plex_enable", "plex_username", "plex_password", "plex_server", "plex_dvrID",
"server_useWatchdog", "epg_TVDBAPIKey", "epg_generate", "DVR_UUID"]
for k in environKeys:
v = os.environ.get(k)
if v is not None:
# environment variable overrides yaml config
section = k.split("_")[0].title()
key = k.split("_")[1]
if v not in ("plex_enable", "server_useWatchdog", "epg_generate"):
dvrConfig[section][key] = type(dvrConfig[section][key])(v)
else:
if v == "true":
v = True
else:
v = False
dvrConfig[section][key] = v