fix(backend): strip title-duplicate and generic words from album search suffix
Album "recognize - Single" produced query "MINA - recognize recognize Single" because "recognize" appeared in both title and album name. Now filters album words already present in the title, plus generic words (Single, EP, Remaster…). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
f1bdd811ca
commit
319a3804f3
1 file changed
+5
-1
@@ -128,8 +128,12 @@ async function downloadTrack({ jobId, artist, rawArtist, albumArtist, title, alb
|
||||
// This helps YTM rank the official OST/album track above fan covers and romaji-subtitle uploads.
|
||||
// Only use album words that are ASCII (romaji/English) — Japanese album words don't help YTM ranking.
|
||||
const hasJpTitle = JP_RE.test(title);
|
||||
const GENERIC_ALBUM_WORDS = new Set(['single', 'ep', 'album', 'soundtrack', 'ost', 'edition', 'remaster', 'remastered', 'deluxe', 'bonus', 'version', 'live']);
|
||||
const titleWordSet = new Set(title.toLowerCase().split(/\s+/));
|
||||
const albumWords = (album && album !== 'Singles' && album !== 'Unknown')
|
||||
? album.split(/\s+/).filter(w => /^[A-Za-z0-9]/.test(w)).slice(0, 2).join(' ')
|
||||
? album.split(/\s+/)
|
||||
.filter(w => /^[A-Za-z0-9]/.test(w) && !titleWordSet.has(w.toLowerCase()) && !GENERIC_ALBUM_WORDS.has(w.toLowerCase()))
|
||||
.slice(0, 2).join(' ')
|
||||
: '';
|
||||
const albumQuerySuffix = (hasJpTitle || (albumWords && titleKws.length <= 1)) && albumWords
|
||||
? ' ' + albumWords : '';
|
||||
|
||||
Reference in new issue
Block a user