diff --git a/beetsplug/rewrite.py b/beetsplug/rewrite.py index a02538902..b92da4f5f 100644 --- a/beetsplug/rewrite.py +++ b/beetsplug/rewrite.py @@ -32,7 +32,7 @@ def rewriter(field, rules): (pattern, replacement) pairs. """ def fieldfunc(item): - value = getattr(item, field) + value = item._values_fixed[field] for pattern, replacement in rules: if pattern.match(value.lower()): # Rewrite activated. @@ -54,7 +54,7 @@ class RewritePlugin(BeetsPlugin): fieldname, pattern = key.split(None, 1) except ValueError: raise ui.UserError("invalid rewrite specification") - if fieldname not in library.ITEM_KEYS: + if fieldname not in library.Item._fields: raise ui.UserError("invalid field name (%s) in rewriter" % fieldname) log.debug(u'adding template field %s' % key) diff --git a/docs/plugins/rewrite.rst b/docs/plugins/rewrite.rst index 8a139b806..d3151bac2 100644 --- a/docs/plugins/rewrite.rst +++ b/docs/plugins/rewrite.rst @@ -1,10 +1,10 @@ Rewrite Plugin ============== -The ``rewrite`` plugin lets you easily substitute values in your path formats. -Specifically, it is intended to let you *canonicalize* names such as artists: -for example, perhaps you want albums from The Jimi Hendrix Experience to be -sorted into the same folder as solo Hendrix albums. +The ``rewrite`` plugin lets you easily substitute values in your templates and +path formats. Specifically, it is intended to let you *canonicalize* names +such as artists: for example, perhaps you want albums from The Jimi Hendrix +Experience to be sorted into the same folder as solo Hendrix albums. To use field rewriting, first enable the plugin by putting ``rewrite`` on your ``plugins`` line. Then, make a ``rewrite:`` section in your config file to @@ -16,7 +16,7 @@ example above:: rewrite: artist The Jimi Hendrix Experience: Jimi Hendrix -This will make ``$artist`` in your path formats expand to "Jimi Hendrix" where it +This will make ``$artist`` in your templates expand to "Jimi Hendrix" where it would otherwise be "The Jimi Hendrix Experience". The pattern is a case-insensitive regular expression. This means you can use @@ -30,5 +30,5 @@ As a convenience, the plugin applies patterns for the ``artist`` field to the ``albumartist`` field as well. (Otherwise, you would probably want to duplicate every rule for ``artist`` and ``albumartist``.) -Note that this plugin only applies to path templating; it does not modify files' +Note that this plugin only applies to templating; it does not modify files' metadata tags or the values tracked by beets' library database.