beets/beetsplug
Šarūnas Nejus 65e935bee5
Perform a regex substitution in the substitute plugin (#5357)
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.
2024-11-22 05:02:50 +00:00
..
bpd Remove some lint exclusions and fix the issues 2024-09-21 11:59:19 +01:00
lastgenre Reformat the codebase 2024-09-21 11:57:48 +01:00
metasync Reformat the codebase 2024-09-21 11:57:48 +01:00
web Reworked #4709 after latest release (#5447) 2024-09-30 10:28:15 +01:00
__init__.py Reformat the codebase 2024-09-21 11:57:48 +01:00
absubmit.py Reformat the codebase 2024-09-21 11:57:48 +01:00
acousticbrainz.py Reformat the codebase 2024-09-21 11:57:48 +01:00
advancedrewrite.py Merge pull request #5063 from Maxr1998/fix-advancedrewrite-simple-rules 2024-03-01 16:08:37 +10:00
albumtypes.py Reformat the codebase 2024-09-21 11:57:48 +01:00
aura.py Reformat the codebase 2024-09-21 11:57:48 +01:00
autobpm.py Add Item.filepath property to simplify path handling 2024-08-19 22:44:17 +01:00
badfiles.py Fix lint issues 2024-09-21 11:59:18 +01:00
bareasc.py Reformat the codebase 2024-09-21 11:57:48 +01:00
beatport.py Reformat the codebase 2024-09-21 11:57:48 +01:00
bench.py Reformat the codebase 2024-09-21 11:57:48 +01:00
bpm.py Reformat the codebase 2024-09-21 11:57:48 +01:00
bpsync.py Reformat the codebase 2024-09-21 11:57:48 +01:00
bucket.py Reformat the codebase 2024-09-21 11:57:48 +01:00
chroma.py Apply formatting tools to all files 2023-10-22 09:53:18 +10:00
convert.py Fix lints 2024-10-30 12:13:30 +00:00
deezer.py Reformat the codebase 2024-09-21 11:57:48 +01:00
discogs.py Fixes TypeError in the Discogs plugin (#5415) 2024-09-19 21:27:16 +01:00
duplicates.py Fix lint issues 2024-09-21 11:59:18 +01:00
edit.py Reformat the codebase 2024-09-21 11:57:48 +01:00
embedart.py Apply formatting tools to all files 2023-10-22 09:53:18 +10:00
embyupdate.py Reformat the codebase 2024-09-21 11:57:48 +01:00
export.py Reformat the codebase 2024-09-21 11:57:48 +01:00
fetchart.py Reformat the codebase 2024-09-21 11:57:48 +01:00
filefilter.py Reformat the codebase 2024-09-21 11:57:48 +01:00
fish.py Reformat the codebase 2024-09-21 11:57:48 +01:00
freedesktop.py Reformat the codebase 2024-09-21 11:57:48 +01:00
fromfilename.py Apply formatting tools to all files 2023-10-22 09:53:18 +10:00
ftintitle.py Hardcode for_artist keyword in ftintitle plugin 2024-09-30 10:24:09 -05:00
fuzzy.py Reformat the codebase 2024-09-21 11:57:48 +01:00
gmusic.py Apply formatting tools to all files 2023-10-22 09:53:18 +10:00
hook.py Apply formatting tools to all files 2023-10-22 09:53:18 +10:00
ihate.py Apply formatting tools to all files 2023-10-22 09:53:18 +10:00
importadded.py Apply formatting tools to all files 2023-10-22 09:53:18 +10:00
importfeeds.py Reformat the codebase 2024-09-21 11:57:48 +01:00
info.py Reformat the codebase 2024-09-21 11:57:48 +01:00
inline.py Reformat the codebase 2024-09-21 11:57:48 +01:00
ipfs.py Reformat the codebase 2024-09-21 11:57:48 +01:00
keyfinder.py Reformat the codebase 2024-09-21 11:57:48 +01:00
kodiupdate.py Add timeout to all requests calls 2024-05-25 12:24:53 -03:00
lastimport.py Update lastimport.py 2023-12-20 10:28:45 -05:00
limit.py Add support for filtering relations 2024-06-21 15:05:29 +01:00
listenbrainz.py lint error 2024-11-10 20:27:41 -05:00
loadext.py Reformat the codebase 2024-09-21 11:57:48 +01:00
lyrics.py Update Tekstowo backend to fetch lyrics directly 2024-10-12 02:14:18 +01:00
mbcollection.py Apply formatting tools to all files 2023-10-22 09:53:18 +10:00
mbsubmit.py mbsubmit: Add picard PromptChoice 2023-12-05 13:49:03 +02:00
mbsync.py Reformat the codebase 2024-09-21 11:57:48 +01:00
missing.py Reformat the codebase 2024-09-21 11:57:48 +01:00
mpdstats.py Apply formatting tools to all files 2023-10-22 09:53:18 +10:00
mpdupdate.py Apply formatting tools to all files 2023-10-22 09:53:18 +10:00
parentwork.py Reformat the codebase 2024-09-21 11:57:48 +01:00
permissions.py Apply formatting 2024-03-01 15:21:25 +10:00
play.py Reformat the codebase 2024-09-21 11:57:48 +01:00
playlist.py Add support for a specific type in InQuery 2024-04-30 22:20:36 +01:00
plexupdate.py Add timeout to all requests calls 2024-05-25 12:24:53 -03:00
random.py Reformat the codebase 2024-09-21 11:57:48 +01:00
replaygain.py Reformat the codebase 2024-09-21 11:57:48 +01:00
rewrite.py Apply formatting tools to all files 2023-10-22 09:53:18 +10:00
scrub.py Reformat the codebase 2024-09-21 11:57:48 +01:00
smartplaylist.py Reformat the codebase 2024-09-21 11:57:48 +01:00
sonosupdate.py Apply formatting tools to all files 2023-10-22 09:53:18 +10:00
spotify.py Add timeout to all requests calls 2024-05-25 12:24:53 -03:00
subsonicplaylist.py Add timeout to all requests calls 2024-05-25 12:24:53 -03:00
subsonicupdate.py Add timeout to all requests calls 2024-05-25 12:24:53 -03:00
substitute.py Apply substitute rules in sequence 2024-10-16 16:36:36 +02:00
the.py Reformat the codebase 2024-09-21 11:57:48 +01:00
thumbnails.py Reformat the codebase 2024-09-21 11:57:48 +01:00
types.py Apply formatting tools to all files 2023-10-22 09:53:18 +10:00
unimported.py bugfix: ignore subdirectories of ignored 2024-03-22 18:20:47 -04:00
zero.py Reformat the codebase 2024-09-21 11:57:48 +01:00