For the moment this is a singleton. One access key will let you stream to any app or stream key. It's denoted in the form of appending a GET parameter to the URL like `?access_key=foobarbaz` This at least means someone who knows the stream URL (frex to view it) won't also be able to stream.
58 lines
1.6 KiB
Python
58 lines
1.6 KiB
Python
"""Config directives for application."""
|
|
|
|
import json
|
|
import os
|
|
from pathlib import Path
|
|
|
|
API_USER = os.getenv("OVENMONITOR_API_USER", "")
|
|
API_PASS = os.getenv("OVENMONITOR_API_PASSWORD", "")
|
|
|
|
ACCESS_KEY = os.getenv("OVENMONITOR_ACCESS_KEY", "")
|
|
|
|
WEBHOOK_URL = os.getenv("OVENMONITOR_WEBHOOK_URL", "")
|
|
WEBHOOK_ONLINE = os.getenv("OVENMONITOR_WEBHOOK_ONLINE", "")
|
|
WEBHOOK_OFFLINE = os.getenv("OVENMONITOR_WEBHOOK_OFFLINE", "")
|
|
WEBHOOK_NAME = os.getenv("OVENMONITOR_WEBHOOK_NAME", "")
|
|
WEBHOOK_AVATAR_PATH = os.getenv("OVENMONITOR_WEBHOOK_AVATARPATH", "")
|
|
WEBHOOK_AVATAR_URL = os.getenv("OVENMONITOR_WEBHOOK_AVATARURL", "")
|
|
WEBHOOK_HEADERS = {"Content-Type": "application/json"}
|
|
|
|
# Notifications/min to halt notifying on
|
|
NOTIFICATION_THROTTLE = 4
|
|
|
|
LAST_STREAM_LIST = []
|
|
NOTIFICATIONS = []
|
|
DISABLED_KEYS = []
|
|
BLOCKED_IPS = []
|
|
DISABLED = False
|
|
|
|
|
|
def load() -> None:
|
|
f = Path(Path.home(), Path(".ome_state.json"))
|
|
if not f.is_file():
|
|
return
|
|
|
|
global DISABLED_KEYS, BLOCKED_IPS, DISABLED
|
|
data = json.loads(f.read_text(encoding="utf-8"))
|
|
DISABLED_KEYS = data["disabled_keys"]
|
|
BLOCKED_IPS = data["blocked_ips"]
|
|
DISABLED = data["is_disabled"]
|
|
|
|
|
|
def save() -> None:
|
|
f = Path(Path.home(), Path(".ome_state.json"))
|
|
data = {"disabled_keys": DISABLED_KEYS, "blocked_ips": BLOCKED_IPS, "is_disabled": DISABLED}
|
|
|
|
f.write_text(json.dumps(data), encoding="utf-8")
|
|
|
|
|
|
def is_api_ready() -> bool:
|
|
return bool(API_USER and API_PASS)
|
|
|
|
|
|
def is_webhook_ready() -> bool:
|
|
return bool(WEBHOOK_URL)
|
|
|
|
|
|
def is_avatar_ready() -> bool:
|
|
return bool(is_webhook_ready() and WEBHOOK_AVATAR_PATH and WEBHOOK_AVATAR_URL)
|