From 319a3804f3704bd574e15fb139996db6a4507303 Mon Sep 17 00:00:00 2001 From: Honey Date: Fri, 19 Jun 2026 09:29:39 +0200 Subject: [PATCH] fix(backend): strip title-duplicate and generic words from album search suffix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- backend/lib/ytdlp.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/lib/ytdlp.js b/backend/lib/ytdlp.js index 6ac9787..e4ed5be 100644 --- a/backend/lib/ytdlp.js +++ b/backend/lib/ytdlp.js @@ -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 : '';