Skip to content

Commit

Permalink
Improve video title filters (#1667)
Browse files Browse the repository at this point in the history
  • Loading branch information
Serial-ATA authored Mar 27, 2024
1 parent 47dbeff commit 3718053
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/providers/song-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,26 +209,28 @@ 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 {
if (!name) {
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;
Expand Down

0 comments on commit 3718053

Please sign in to comment.