fixed feat removal issue

This commit is contained in:
RemixDev 2022-01-02 13:53:00 +01:00
parent b983712086
commit 1863557f49

View file

@ -50,17 +50,20 @@ def removeFeatures(title):
clean = title clean = title
found = False found = False
pos = -1 pos = -1
if re.search(r"[\s(]?feat\.?\s", clean): if re.search(r"[\s(]\(?\s?feat\.?\s", clean):
pos = re.search(r"[\s(]?feat\.?\s", clean).start(0) pos = re.search(r"[\s(]\(?\s?feat\.?\s", clean).start(0)
found = True found = True
if re.search(r"[\s(]?ft\.?\s", clean): if re.search(r"[\s(]\(?\s?ft\.?\s", clean):
pos = re.search(r"[\s(]?ft\.?\s", clean).start(0) pos = re.search(r"[\s(]\(?\s?ft\.?\s", clean).start(0)
found = True found = True
openBracket = clean[pos] == '(' openBracket = clean[pos] == '(' or clean[pos+1] == '('
otherBracket = clean.find('(', pos+2)
if found: if found:
tempTrack = clean[:pos] tempTrack = clean[:pos]
if ")" in clean and openBracket: if ")" in clean and openBracket:
tempTrack += clean[clean.find(")", pos + 1) + 1:] tempTrack += clean[clean.find(")", pos+2) + 1:]
if not openBracket and otherBracket != -1:
tempTrack += f" {clean[otherBracket:]}"
clean = tempTrack.strip() clean = tempTrack.strip()
clean = ' '.join(clean.split()) clean = ' '.join(clean.split())
return clean return clean