diff --git a/command.py b/command.py index dcf4da3..ecc451f 100644 --- a/command.py +++ b/command.py @@ -199,17 +199,14 @@ def cmd_play(bot, user, text, command, parameter): index = int(params[0]) else: bot.send_msg(constants.strings('invalid_index', index=parameter), text) + return if len(params) > 1: - _start_at = params[1] - match = re.search("(?:(\d\d):)?(?:(\d\d):)?(\d\d(?:\.\d*)?)", _start_at, flags=re.IGNORECASE) - if match: - if match[1] is None and match[2] is None: - start_at = float(match[3]) - elif match[2] is None: - start_at = float(match[3]) + 60 * int(match[1]) - else: - start_at = float(match[3]) + 60 * int(match[2]) + 3600 * int(match[2]) + try: + start_at = util.parse_time(params[1]) + except ValueError: + bot.send_msg(constants.strings('bad_parameter', command=command), text) + return if len(var.playlist) > 0: if index != -1: diff --git a/configuration.default.ini b/configuration.default.ini index 1da9495..909991a 100644 --- a/configuration.default.ini +++ b/configuration.default.ini @@ -104,6 +104,9 @@ access_address = http://127.0.0.1:8181 flask_secret = ChangeThisPassword +upload_enabled = True +maximum_upload_file_size = 30M + [debug] # Set ffmpeg to True if you want to display DEBUG level log of ffmpeg. ffmpeg = False diff --git a/configuration.example.ini b/configuration.example.ini index 1e4a480..1062771 100644 --- a/configuration.example.ini +++ b/configuration.example.ini @@ -140,6 +140,11 @@ port = 64738 # !! YOU NEED TO CHANGE IT IF auth_method IS 'token'!! # flask_secret = ChangeThisPassword +# 'upload_enabled': Enable the upload function of the web interface. +# 'maximum_upload_file_size': Unit can be 'B', 'KB', 'MB', 'GB', 'TB'. +#upload_enabled = True +#maximum_upload_file_size = 30MB + # [debug] stores some debug settings. [debug] # 'ffmpeg': Set ffmpeg to True if you want to display DEBUG level log of ffmpeg. diff --git a/interface.py b/interface.py index 3eb95a6..c1645c2 100644 --- a/interface.py +++ b/interface.py @@ -187,10 +187,13 @@ def index(): time.sleep(0.1) tags_color_lookup = build_tags_color_lookup() + max_upload_file_size = util.parse_file_size(var.config.get("webinterface", "max_upload_file_size", fallback="30MB")) return render_template('index.html', dirs=get_all_dirs(), + upload_enabled=var.config.getboolean("webinterface", "upload_enabled", fallback=True), tags_color_lookup=tags_color_lookup, + max_upload_file_size=max_upload_file_size ) @@ -614,6 +617,9 @@ def library(): def upload(): global log + if not var.config.getboolean("webinterface", "upload_enabled", fallback=True): + abort(403) + file = request.files['file'] if not file: abort(400) diff --git a/templates/index.html b/templates/index.html index f7ca1ab..a0f56ee 100644 --- a/templates/index.html +++ b/templates/index.html @@ -327,7 +327,7 @@ - +{% if upload_enabled %}