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: