From 10a85e04977586ab6b0417134194ed06fe6a066c Mon Sep 17 00:00:00 2001 From: Honey Date: Sat, 2 May 2026 12:35:19 +0200 Subject: [PATCH] fix(ui): playlist match - use first artist only, strip punctuation, increase songCount MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit "Kløn, Renzyx" → search with "Kløn Alone", compare "kløn" == "kløn" (not "kløn,") songCount raised to 20 so generic titles like "Alone" have better recall. Co-Authored-By: Claude Sonnet 4.6 --- src/ui.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/ui.js b/src/ui.js index ce6a5d6..3cad145 100644 --- a/src/ui.js +++ b/src/ui.js @@ -357,13 +357,16 @@ async function _createNdPlaylist(tracks, name) { if (!t.trackName) continue; const missingLabel = t.artistName ? `${t.artistName} – ${t.trackName}` : t.trackName; try { - // Search with artist+title first for precision, fall back to title-only with more results - const artistQuery = t.artistName ? `${t.artistName} ${t.trackName}` : t.trackName; - const r = await api('search3', `&query=${encodeURIComponent(artistQuery)}&songCount=10&albumCount=0&artistCount=0`); + // Use first artist only for search to avoid comma/multi-artist confusion + const firstArtist = t.artistName ? t.artistName.split(/[,/•]/)[0].trim() : ''; + const artistQuery = firstArtist ? `${firstArtist} ${t.trackName}` : t.trackName; + const r = await api('search3', `&query=${encodeURIComponent(artistQuery)}&songCount=20&albumCount=0&artistCount=0`); const songs = r.searchResult3?.song || []; + // Strip trailing punctuation from first word so "Kløn," matches "Kløn" + const firstWord = s => norm(s).split(/[\s,/•]+/)[0].replace(/\W+$/, ''); const match = songs.find(s => norm(s.title) === norm(t.trackName) && - norm(s.artist).split(' ')[0] === norm(t.artistName).split(' ')[0] + firstWord(s.artist) === firstWord(firstArtist || t.artistName) ) || songs.find(s => norm(s.title) === norm(t.trackName)); if (match) songIds.push(match.id); else missing.push(missingLabel);