mirror of
https://gitlab.com/RemixDev/deemix-py.git
synced 2024-12-28 02:26:14 +00:00
Add more cases for feat. removal
This commit is contained in:
parent
7f1eb0c500
commit
09511fb379
|
@ -1,4 +1,5 @@
|
||||||
import string
|
import string
|
||||||
|
import re
|
||||||
from deezer import TrackFormats
|
from deezer import TrackFormats
|
||||||
import os
|
import os
|
||||||
from deemix.errors import ErrorMessages
|
from deemix.errors import ErrorMessages
|
||||||
|
@ -47,10 +48,18 @@ def changeCase(txt, case_type):
|
||||||
|
|
||||||
def removeFeatures(title):
|
def removeFeatures(title):
|
||||||
clean = title
|
clean = title
|
||||||
if "(feat." in clean.lower():
|
found = False
|
||||||
pos = clean.lower().find("(feat.")
|
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]
|
tempTrack = clean[:pos]
|
||||||
if ")" in clean:
|
if ")" in clean and openBracket:
|
||||||
tempTrack += clean[clean.find(")", pos + 1) + 1:]
|
tempTrack += clean[clean.find(")", pos + 1) + 1:]
|
||||||
clean = tempTrack.strip()
|
clean = tempTrack.strip()
|
||||||
clean = ' '.join(clean.split())
|
clean = ' '.join(clean.split())
|
||||||
|
|
Loading…
Reference in a new issue