Skip to content

Commit

Permalink
smart_title_case: Fixed regex replace groups clashing with artist nam…
Browse files Browse the repository at this point in the history
…es starting with number

Use \g<N> instead of just \gN
  • Loading branch information
phw committed Dec 30, 2022
1 parent 30648b9 commit ffa143d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions plugins/smart_title_case/smart_title_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
For Artist/AlbumArtist, title cases only artists not join phrases<br />
e.g. The Beatles feat. The Who.
"""
PLUGIN_VERSION = "0.4"
PLUGIN_VERSION = "0.4.1"
PLUGIN_API_VERSIONS = ["2.0"]
PLUGIN_LICENSE = "GPL-2.0-or-later"
PLUGIN_LICENSE_URL = "https://www.gnu.org/licenses/gpl-3.0.html"
Expand Down Expand Up @@ -69,7 +69,7 @@ def artist_title_case(text, artists, artists_upper):
and the join strings to leave as-is.
"""
find = "^(" + r")(\s+\S+?\s+)(".join((map(re.escape, map(string_cleanup,artists)))) + ")(.*$)"
replace = "".join([r"%s\%d" % (a, x*2 + 2) for x, a in enumerate(artists_upper)])
replace = "".join([r"%s\g<%d>" % (a, x*2 + 2) for x, a in enumerate(artists_upper)])
result = re.sub(find, replace, string_cleanup(text))
return result

Expand Down

0 comments on commit ffa143d

Please sign in to comment.