fixed feat removal issue

This commit is contained in:
RemixDev 2022-01-02 13:35:34 +01:00
parent baad2d0d67
commit d561b26c98

View file

@ -42,19 +42,22 @@ function removeFeatures(title){
let clean = title
let found = false
let pos
if (clean.search(/[\s(]?feat\.?\s/gi) != -1){
pos = clean.search(/[\s(]?feat\.?\s/gi)
if (clean.search(/[\s(]\(?\s?feat\.?\s/gi) != -1){
pos = clean.search(/[\s(]\(?\s?feat\.?\s/gi)
found = true
}
if (clean.search(/[\s(]?ft\.?\s/gi) != -1){
pos = clean.search(/[\s(]?ft\.?\s/gi)
if (clean.search(/[\s(]\(?\s?ft\.?\s/gi) != -1){
pos = clean.search(/[\s(]\(?\s?ft\.?\s/gi)
found = true
}
const openBracket = clean[pos] == '('
const openBracket = clean[pos] == '(' || clean[pos+1] == '('
const otherBracket = clean.indexOf('(', pos+2)
if (found) {
let tempTrack = clean.slice(0, pos)
if (clean.includes(')') && openBracket)
tempTrack += clean.slice(clean.indexOf(')', pos+1)+1)
tempTrack += clean.slice(clean.indexOf(')', pos+2)+1)
if (!openBracket && otherBracket != -1)
tempTrack += ` ${clean.slice(otherBracket)}`
clean = tempTrack.trim()
clean = clean.replace(/\s\s+/g, ' ') // remove extra spaces
}