diff --git a/picard/script.py b/picard/script.py index 73e84664e..38c361bf7 100644 --- a/picard/script.py +++ b/picard/script.py @@ -684,6 +684,18 @@ def func_firstwords(parser, text, length): return text[:length].rsplit(' ', 1)[0] +def func_startswith(parser, text, pattern): + if text.startswith(pattern): + return "1" + return "0" + + +def func_endswith(parser, text, pattern): + if text.endswith(pattern): + return "1" + return "0" + + def func_truncate(parser, text, length): try: length = int(length) @@ -817,6 +829,8 @@ register_script_function(func_is_complete, "is_complete") register_script_function(func_firstalphachar, "firstalphachar") register_script_function(func_initials, "initials") register_script_function(func_firstwords, "firstwords") +register_script_function(func_startswith, "startswith") +register_script_function(func_endswith, "endswith") register_script_function(func_truncate, "truncate") register_script_function(func_swapprefix, "swapprefix", check_argcount=False) register_script_function(func_delprefix, "delprefix", check_argcount=False)