From 6068d644b98db93e436a0e64f36031b287ab4eab Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sun, 5 Sep 2021 01:26:34 -0700 Subject: [PATCH] Add autorefresh to Channel to include/exclude in refresh_all loop. --- .../backend/endpoints/channel_endpoints.py | 14 +++++++++ frontends/ycdl_flask/static/js/api.js | 8 +++++ frontends/ycdl_flask/templates/channel.html | 23 ++++++++++++++ frontends/ycdl_flask/templates/channels.html | 5 ++- utilities/database_upgrader.py | 31 +++++++++++++++++++ ycdl/constants.py | 5 +-- ycdl/objects.py | 21 +++++++++++++ ycdl/ycdldb.py | 13 +++++--- 8 files changed, 112 insertions(+), 8 deletions(-) diff --git a/frontends/ycdl_flask/backend/endpoints/channel_endpoints.py b/frontends/ycdl_flask/backend/endpoints/channel_endpoints.py index 225f0d0..adc1342 100644 --- a/frontends/ycdl_flask/backend/endpoints/channel_endpoints.py +++ b/frontends/ycdl_flask/backend/endpoints/channel_endpoints.py @@ -159,6 +159,20 @@ def post_set_automark(channel_id): return flasktools.make_json_response({}) +@flasktools.required_fields(['autorefresh'], forbid_whitespace=True) +@site.route('/channel//set_autorefresh', methods=['POST']) +def post_set_autorefresh(channel_id): + autorefresh = request.form['autorefresh'] + channel = common.ycdldb.get_channel(channel_id) + + try: + autorefresh = stringtools.truthystring(autorefresh) + channel.set_autorefresh(autorefresh) + except (ValueError, TypeError): + flask.abort(400) + + return flasktools.make_json_response({}) + @site.route('/channel//set_download_directory', methods=['POST']) def post_set_download_directory(channel_id): download_directory = request.form['download_directory'] diff --git a/frontends/ycdl_flask/static/js/api.js b/frontends/ycdl_flask/static/js/api.js index c887dee..3cdba57 100644 --- a/frontends/ycdl_flask/static/js/api.js +++ b/frontends/ycdl_flask/static/js/api.js @@ -43,6 +43,14 @@ function set_automark(channel_id, state, callback) return common.post(url, data, callback); } +api.channels.set_autorefresh = +function set_autorefresh(channel_id, autorefresh, callback) +{ + const url = `/channel/${channel_id}/set_autorefresh`; + const data = {"autorefresh": autorefresh}; + return common.post(url, data, callback); +} + api.channels.set_download_directory = function set_download_directory(channel_id, download_directory, callback) { diff --git a/frontends/ycdl_flask/templates/channel.html b/frontends/ycdl_flask/templates/channel.html index 9f74766..ec31943 100644 --- a/frontends/ycdl_flask/templates/channel.html +++ b/frontends/ycdl_flask/templates/channel.html @@ -259,6 +259,11 @@ https://stackoverflow.com/a/35153397
+
+ + +
+
New videos are: