metadata-filter icon indicating copy to clipboard operation
metadata-filter copied to clipboard

Clean multiple artists

Open chaos-baum opened this issue 1 year ago • 1 comments

I have often encountered the problem that on youtube (and other platform) the artists are seperated by tags like: [",", "&", "x"] which causes the following. grafik grafik

I used something like the following in my script. The point is to extract just the first artist via Regex because last.fm only handles it correctly that way.

function cleanupArtist(artist: string) {
	// Define patterns to find additional artists or features.
	const patterns = [/ & .*/, / x .*/, / feat\..*/];

	let cleanedArtist = artist;

	patterns.forEach((pattern) => {
		cleanedArtist = cleanedArtist.replace(pattern, '');
	});

	return cleanedArtist.trim();
}

chaos-baum avatar Dec 21 '23 15:12 chaos-baum

@Ceddicedced Thanks for sharing this. Not sure if it'll get merged in, but it was exactly what I needed for my project after identifying this same problem.

jbwharris avatar Aug 15 '24 23:08 jbwharris