41 lines
1.1 KiB
Python
41 lines
1.1 KiB
Python
from .config import settings
|
|
from .db import get_settings_overrides
|
|
|
|
_INT_FIELDS = {
|
|
"sonarr_quality_profile_id",
|
|
"radarr_quality_profile_id",
|
|
"jwt_exp_minutes",
|
|
"requests_sync_ttl_minutes",
|
|
"requests_poll_interval_seconds",
|
|
"requests_delta_sync_interval_minutes",
|
|
"requests_cleanup_days",
|
|
}
|
|
_BOOL_FIELDS = {
|
|
"jellyfin_sync_to_arr",
|
|
"site_banner_enabled",
|
|
}
|
|
_SKIP_OVERRIDE_FIELDS = {"site_build_number"}
|
|
|
|
|
|
def get_runtime_settings():
|
|
overrides = get_settings_overrides()
|
|
update = {}
|
|
for key, value in overrides.items():
|
|
if value is None:
|
|
continue
|
|
if key in _SKIP_OVERRIDE_FIELDS:
|
|
continue
|
|
if key in _INT_FIELDS:
|
|
try:
|
|
update[key] = int(value)
|
|
except (TypeError, ValueError):
|
|
continue
|
|
elif key in _BOOL_FIELDS:
|
|
if isinstance(value, bool):
|
|
update[key] = value
|
|
else:
|
|
update[key] = str(value).strip().lower() in {"1", "true", "yes", "on"}
|
|
else:
|
|
update[key] = value
|
|
return settings.model_copy(update=update)
|