From 1863557f49c8eb3a2de407d684b348bc32729d22 Mon Sep 17 00:00:00 2001 From: RemixDev Date: Sun, 2 Jan 2022 13:53:00 +0100 Subject: [PATCH] fixed feat removal issue --- deemix/utils/__init__.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/deemix/utils/__init__.py b/deemix/utils/__init__.py index cfb4e64..c9ff6d9 100644 --- a/deemix/utils/__init__.py +++ b/deemix/utils/__init__.py @@ -50,17 +50,20 @@ def removeFeatures(title): clean = title found = False pos = -1 - if re.search(r"[\s(]?feat\.?\s", clean): - pos = re.search(r"[\s(]?feat\.?\s", clean).start(0) + if re.search(r"[\s(]\(?\s?feat\.?\s", clean): + pos = re.search(r"[\s(]\(?\s?feat\.?\s", clean).start(0) found = True - if re.search(r"[\s(]?ft\.?\s", clean): - pos = re.search(r"[\s(]?ft\.?\s", clean).start(0) + if re.search(r"[\s(]\(?\s?ft\.?\s", clean): + pos = re.search(r"[\s(]\(?\s?ft\.?\s", clean).start(0) found = True - openBracket = clean[pos] == '(' + openBracket = clean[pos] == '(' or clean[pos+1] == '(' + otherBracket = clean.find('(', pos+2) if found: tempTrack = clean[:pos] 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 = ' '.join(clean.split()) return clean