diff --git a/tubearchivist/home/src/config.py b/tubearchivist/home/src/config.py index 273f5af..d35c63d 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 cf4d54d..4e018c1 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 e1b4ce9..8c99010 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 %}
+

User Configurations

@@ -163,8 +165,8 @@ {{ scheduler_form.check_reindex }}
-

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 }}
@@ -273,4 +275,5 @@ {% endif %} + {% endblock content %} \ No newline at end of file diff --git a/tubearchivist/home/views.py b/tubearchivist/home/views.py index 5cc04e7..7116cfc 100644 --- a/tubearchivist/home/views.py +++ b/tubearchivist/home/views.py @@ -948,6 +948,7 @@ class SettingsView(View): print(form_post) ScheduleBuilder().update_schedule_conf(form_post) + sleep(1) return redirect("settings", permanent=True) diff --git a/tubearchivist/static/progress.js b/tubearchivist/static/progress.js index 68affda..36471b4 100644 --- a/tubearchivist/static/progress.js +++ b/tubearchivist/static/progress.js @@ -1,5 +1,5 @@ /** - * Handle progress bar on /download + * Handle multi channel notifications * */ @@ -10,7 +10,8 @@ const messageTypes = { "download": ["message:download", "message:add", "message:rescan"], "channel": ["message:subchannel"], "channel_id": ["message:playlistscan"], - "playlist": ["message:subplaylist"] + "playlist": ["message:subplaylist"], + "setting": ["message:setting"] } // start to look for messages