Skip to content

Commit

Permalink
Merge pull request beetbox#5051 from Maxr1998/advancedrewrite-docs-qu…
Browse files Browse the repository at this point in the history
…ote-issues

advancedrewrite: Add note about quoting issues to docs
  • Loading branch information
sampsyo authored Dec 15, 2023
2 parents 1efd67c + 6e5bcbc commit d456166
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions docs/plugins/advancedrewrite.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,31 @@ 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``.)

Make sure to properly quote your query strings if they contain spaces,
otherwise they might not do what you expect, or even cause beets to crash.

Take the following example::

advancedrewrite:
# BAD, DON'T DO THIS!
- match: album:THE ALBUM
replacements:
artist: New artist

On the first sight, this might look sane, and replace the artist of the album
*THE ALBUM* with *New artist*. However, due to the space and missing quotes,
this query will evaluate to ``album:THE`` and match ``ALBUM`` on any field,
including ``artist``. As ``artist`` is the field being replaced,
this query will result in infinite recursion and ultimately crash beets.

Instead, you should use the following rule::

advancedrewrite:
# Note the quotes around the query string!
- match: album:"THE ALBUM"
replacements:
artist: New artist

A word of warning: This plugin theoretically only applies to templates and path
formats; it initially does not modify files' metadata tags or the values
tracked by beets' library database, but since it *rewrites all field lookups*,
Expand Down

0 comments on commit d456166

Please sign in to comment.