Browse files

Add a new $setlist() function to tagger script which will take the pa…

…ssed value and split it by the optional third parameter (or by '; ', the default used by Metadata.__get__) before setting it. This allows manipulation in text of multi-valued fields such as composers, performers etc; while still being able to write them correctly as multi-valued fields in ID3v2.4 etc.
  • Loading branch information...
chad-wilson committed Jan 7, 2012
1 parent 7053642 commit 47fa54da875c186d7daf9c21d00b08806dcb09b5
Showing with 7 additions and 0 deletions.
  1. +7 −0 picard/
@@ -334,12 +334,18 @@ def func_set(parser, name, value):
func_unset(parser, name)
return ""
+def func_setlist(parser, name, value, split_chars = '; '):
+ """Sets the variable ``name`` to ``value`` as a list; splitting by the passed string."""
+ func_set(parser, name, value.split(split_chars) if value else value)
def func_get(parser, name):
"""Returns the variable ``name`` (equivalent to ``%name%``)."""
if name.startswith("_"):
name = "~" + name[1:]
return parser.context.get(name, u"")
def func_copy(parser, new, old):
"""Copies content of variable ``old`` to variable ``new``."""
if new.startswith("_"):
@@ -525,6 +531,7 @@ def func_truncate(parser, text, length):
register_script_function(func_num, "num")
register_script_function(func_unset, "unset")
register_script_function(func_set, "set")
+register_script_function(func_setlist, "setlist")
register_script_function(func_get, "get")
register_script_function(func_trim, "trim")
register_script_function(func_add, "add")

0 comments on commit 47fa54d

Please sign in to comment.