From 371805334b0d24568c20db3fae31455b2c99eea1 Mon Sep 17 00:00:00 2001 From: Alex <69764315+Serial-ATA@users.noreply.github.com> Date: Wed, 27 Mar 2024 13:54:16 -0400 Subject: [PATCH] Improve video title filters (#1667) --- src/providers/song-info.ts | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/providers/song-info.ts b/src/providers/song-info.ts index 8216a53471..d5fd8b9f56 100644 --- a/src/providers/song-info.ts +++ b/src/providers/song-info.ts @@ -209,10 +209,19 @@ const registerProvider = (win: BrowserWindow) => { }; const suffixesToRemove = [ - ' - topic', - 'vevo', - ' (performance video)', - ' (clip official)', + // Artist names + /\s*(- topic)$/i, + /\s*vevo$/i, + + // Video titles + /\s*[(|\[]official(.*?)[)|\]]/i, // (Official Music Video), [Official Visualizer], etc... + /\s*[(|\[]((lyrics?|visualizer|audio)\s*(video)?)[)|\]]/i, + /\s*[(|\[](performance video)[)|\]]/i, + /\s*[(|\[](clip official)[)|\]]/i, + /\s*[(|\[](video version)[)|\]]/i, + /\s*[(|\[](HD|HQ)\s*?(?:audio)?[)|\]]$/i, + /\s*[(|\[](live)[)|\]]$/i, + /\s*[(|\[]4K\s*?(?:upgrade)?[)|\]]$/i, ]; export function cleanupName(name: string): string { @@ -220,15 +229,8 @@ export function cleanupName(name: string): string { return name; } - name = name.replace( - /\((?:official)? ?(?:music)? ?(?:lyrics?)? ?(?:video)?\)$/i, - '', - ); - const lowCaseName = name.toLowerCase(); for (const suffix of suffixesToRemove) { - if (lowCaseName.endsWith(suffix)) { - return name.slice(0, -suffix.length); - } + name = name.replace(suffix, ''); } return name;