mirror of
https://github.com/beetbox/beets.git
synced 2025-12-06 08:39:17 +01:00
This utilises regex substitution in the substitute plugin. The previous approach only used regex to match the pattern, then replaced it with a static string. This change allows more complex substitutions, where the output depends on the input. ### Example use case Say we want to keep only the first artist of a multi-artist credit, as in the following list: ``` Neil Young & Crazy Horse -> Neil Young Michael Hurley, The Holy Modal Rounders, Jeffrey Frederick & The Clamtones -> Michael Hurley James Yorkston and the Athletes -> James Yorkston ```` This would previously have required three separate rules, one for each resulting artist. By using a regex substitution, we can get the desired behaviour in a single rule: ```yaml substitute: ^(.*?)(,| &| and).*: \1 ``` (Capture the text until the first `,` ` &` or ` and`, then use that capture group as the output) ### Notes I've kept the previous behaviour of only applying the first matching rule, but I'm not 100% sure it's the ideal approach. I can imagine both cases where you want to apply several rules in sequence and cases where you want to stop after the first match. |
||
|---|---|---|
| .. | ||
| plugins | ||
| rsrc | ||
| __init__.py | ||
| conftest.py | ||
| test_art_resize.py | ||
| test_autotag.py | ||
| test_config_command.py | ||
| test_datequery.py | ||
| test_dbcore.py | ||
| test_files.py | ||
| test_hidden.py | ||
| test_importer.py | ||
| test_library.py | ||
| test_logging.py | ||
| test_m3ufile.py | ||
| test_mb.py | ||
| test_metasync.py | ||
| test_pipeline.py | ||
| test_plugins.py | ||
| test_query.py | ||
| test_sort.py | ||
| test_template.py | ||
| test_ui.py | ||
| test_ui_commands.py | ||
| test_ui_importer.py | ||
| test_ui_init.py | ||
| test_util.py | ||
| test_vfs.py | ||
| testall.py | ||