diff --git a/frontends/ycdl_flask/backend/endpoints/channel_endpoints.py b/frontends/ycdl_flask/backend/endpoints/channel_endpoints.py index 7d97768..0725958 100644 --- a/frontends/ycdl_flask/backend/endpoints/channel_endpoints.py +++ b/frontends/ycdl_flask/backend/endpoints/channel_endpoints.py @@ -147,6 +147,7 @@ def post_refresh_all_channels(): common.ycdldb.refresh_all_channels(force=force, skip_failures=True, commit=True) return flasktools.json_response({}) +@flasktools.required_fields(['state'], forbid_whitespace=True) @site.route('/channel//set_automark', methods=['POST']) def post_set_automark(channel_id): state = request.form['state'] @@ -173,6 +174,7 @@ def post_set_autorefresh(channel_id): return flasktools.json_response({}) +@flasktools.required_fields(['download_directory'], forbid_whitespace=False) @site.route('/channel//set_download_directory', methods=['POST']) def post_set_download_directory(channel_id): download_directory = request.form['download_directory'] @@ -202,6 +204,7 @@ def post_set_name(channel_id): response = {'name': channel.name} return flasktools.json_response(response) +@flasktools.required_fields(['extension'], forbid_whitespace=False) @site.route('/channel//set_queuefile_extension', methods=['POST']) def post_set_queuefile_extension(channel_id): extension = request.form['extension'] diff --git a/frontends/ycdl_flask/backend/endpoints/video_endpoints.py b/frontends/ycdl_flask/backend/endpoints/video_endpoints.py index 64fdf33..3eaa248 100644 --- a/frontends/ycdl_flask/backend/endpoints/video_endpoints.py +++ b/frontends/ycdl_flask/backend/endpoints/video_endpoints.py @@ -8,10 +8,9 @@ from .. import common site = common.site +@flasktools.required_fields(['video_ids', 'state'], forbid_whitespace=True) @site.route('/mark_video_state', methods=['POST']) def post_mark_video_state(): - if 'video_ids' not in request.form or 'state' not in request.form: - flask.abort(400) video_ids = request.form['video_ids'] state = request.form['state'] try: @@ -31,10 +30,9 @@ def post_mark_video_state(): return flasktools.json_response({'video_ids': video_ids, 'state': state}) +@flasktools.required_fields(['video_ids'], forbid_whitespace=True) @site.route('/start_download', methods=['POST']) def post_start_download(): - if 'video_ids' not in request.form: - flask.abort(400) video_ids = request.form['video_ids'] try: video_ids = video_ids.split(',')