Add more cases for feat. removal

This commit is contained in:
RemixDev 2021-12-19 17:40:00 +01:00
parent 7f1eb0c500
commit 09511fb379
No known key found for this signature in database
GPG Key ID: B33962B465BDB51C
1 changed files with 12 additions and 3 deletions

View File

@ -1,4 +1,5 @@
import string
import re
from deezer import TrackFormats
import os
from deemix.errors import ErrorMessages
@ -47,10 +48,18 @@ def changeCase(txt, case_type):
def removeFeatures(title):
clean = title
if "(feat." in clean.lower():
pos = clean.lower().find("(feat.")
found = False
pos = -1
if re.search(r"[\s(]?feat\.?\s", clean):
pos = re.search(r"[\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)
found = True
openBracket = clean[pos] == '('
if found:
tempTrack = clean[:pos]
if ")" in clean:
if ")" in clean and openBracket:
tempTrack += clean[clean.find(")", pos + 1) + 1:]
clean = tempTrack.strip()
clean = ' '.join(clean.split())