mirror of
https://github.com/beetbox/beets.git
synced 2026-02-24 00:02:20 +01:00
remove capturing parentheses
This commit is contained in:
parent
693e994729
commit
829b623665
3 changed files with 9 additions and 9 deletions
|
|
@ -683,12 +683,12 @@ def max_filename_length(path, limit=MAX_FILENAME_LENGTH):
|
|||
def feat_tokens(for_artist=True):
|
||||
"""Returns the tokens to use to detect featuring artists in strings."""
|
||||
|
||||
FEAT_SPECIAL_CHARS = ['&', 'feat.', 'ft.']
|
||||
FEAT_WORDS = ['ft', 'featuring', 'feat']
|
||||
feat_special_chars = ['&', 'feat.', 'ft.']
|
||||
feat_words = ['ft', 'featuring', 'feat']
|
||||
if for_artist: # appending to artist name enables more tokens
|
||||
FEAT_WORDS += ['with', 'vs', 'and', 'con']
|
||||
regex = r'(%s)' % '|'.join(['\\b%s\\b' % re.escape(x) for x in FEAT_WORDS])
|
||||
feat_words += ['with', 'vs', 'and', 'con']
|
||||
regex = r'%s' % '|'.join(['\\b%s\\b' % re.escape(x) for x in feat_words])
|
||||
if for_artist:
|
||||
regex = r'(%s|%s)' % \
|
||||
('|'.join([re.escape(x) for x in FEAT_SPECIAL_CHARS]), regex)
|
||||
regex = r'%s|%s' % \
|
||||
('|'.join([re.escape(x) for x in feat_special_chars]), regex)
|
||||
return regex
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ def split_on_feat(artist):
|
|||
may be a string or None if none is present.
|
||||
"""
|
||||
# split on the first "feat".
|
||||
regex = re.compile(feat_tokens().translate(None, '()'), re.IGNORECASE)
|
||||
regex = re.compile(feat_tokens(), re.IGNORECASE)
|
||||
parts = [s.strip() for s in regex.split(artist, 1)]
|
||||
if len(parts) == 1:
|
||||
return parts[0], None
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ def search_pairs(item):
|
|||
artists = [artist]
|
||||
|
||||
# Remove any featuring artists from the artists name
|
||||
pattern = r"(.*?) %s" % feat_tokens()
|
||||
pattern = r"(.*?) (%s)" % feat_tokens()
|
||||
match = re.search(pattern, artist, re.IGNORECASE)
|
||||
if match:
|
||||
artists.append(match.group(1))
|
||||
|
|
@ -151,7 +151,7 @@ def search_pairs(item):
|
|||
titles.append(match.group(1))
|
||||
|
||||
# Remove any featuring artists from the title
|
||||
pattern = r"(.*?) %s" % feat_tokens(for_artist=False)
|
||||
pattern = r"(.*?) (%s)" % feat_tokens(for_artist=False)
|
||||
for title in titles[:]:
|
||||
match = re.search(pattern, title, re.IGNORECASE)
|
||||
if match:
|
||||
|
|
|
|||
Loading…
Reference in a new issue