diff --git a/tubearchivist/home/src/config.py b/tubearchivist/home/src/config.py index 273f5af1..d35c63d6 100644 --- a/tubearchivist/home/src/config.py +++ b/tubearchivist/home/src/config.py @@ -175,11 +175,30 @@ class ScheduleBuilder: for key, value in form_post.items(): to_check = value[0] if key in self.SCHEDULES and to_check: - to_write = self.value_builder(key, to_check) + try: + to_write = self.value_builder(key, to_check) + except ValueError: + print(f"failed: {key} {to_check}") + mess_dict = { + "status": "message:setting", + "level": "error", + "title": "Scheduler update failed.", + "message": "Invalid schedule input", + } + RedisArchivist().set_message("message:setting", mess_dict) + return + redis_config["scheduler"][key] = to_write if key in self.CONFIG and to_check: redis_config["scheduler"][key] = int(to_check) RedisArchivist().set_message("config", redis_config, expire=False) + mess_dict = { + "status": "message:setting", + "level": "info", + "title": "Scheduler changed.", + "message": "Please restart container for changes to take effect", + } + RedisArchivist().set_message("message:setting", mess_dict) def value_builder(self, key, to_check): """validate single cron form entry and return cron dict""" @@ -196,7 +215,8 @@ class ScheduleBuilder: values = to_check.split() if len(keys) != len(values): - raise ValueError(f"failed to parse {to_check} for {key}") + print(f"failed to parse {to_check} for {key}") + raise ValueError("invalid input") to_write = dict(zip(keys, values)) if "*" in to_write["minute"]: diff --git a/tubearchivist/home/src/helper.py b/tubearchivist/home/src/helper.py index cf4d54da..4e018c1a 100644 --- a/tubearchivist/home/src/helper.py +++ b/tubearchivist/home/src/helper.py @@ -162,6 +162,7 @@ class RedisArchivist: "subchannel", "subplaylist", "playlistscan", + "setting", ] def __init__(self): diff --git a/tubearchivist/home/templates/home/settings.html b/tubearchivist/home/templates/home/settings.html index e1b4ce98..8c990103 100644 --- a/tubearchivist/home/templates/home/settings.html +++ b/tubearchivist/home/templates/home/settings.html @@ -1,6 +1,8 @@ {% extends "home/base.html" %} +{% load static %} {% block content %}
Current refresh for metadata older than, in days: {{ config.scheduler.check_reindex_days }}
-Refresh videos older than, in days:
+Current refresh for metadata older than x days: {{ config.scheduler.check_reindex_days }}
+Refresh older than x days, recommended 90:
{{ scheduler_form.check_reindex_days }}