From 941a486913c02321eed0144e874ef6826366030c Mon Sep 17 00:00:00 2001 From: Honey Date: Sun, 3 May 2026 12:42:06 +0200 Subject: [PATCH] fix: strip only Unicode symbols from artist name for ytsearch queries MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Using the full artist name with Unicode symbols (e.g. ☆NoAki☆) in ytsearch caused YouTube to return 0-1 completely irrelevant results, letting wrong songs fall through to the no-filter fallback. Strip only \p{S} (Unicode symbol chars like ☆ ★ ♥) but keep ASCII punctuation — so N!GHT stays "N!GHT" (important for disambiguation) while ☆NoAki☆ becomes "NoAki" (searchable). YTM URL still uses the original artist name with all chars intact. Co-Authored-By: Claude Sonnet 4.6 --- backend/lib/ytdlp.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/backend/lib/ytdlp.js b/backend/lib/ytdlp.js index ed3894d..2c5326e 100644 --- a/backend/lib/ytdlp.js +++ b/backend/lib/ytdlp.js @@ -64,10 +64,11 @@ async function downloadTrack({ jobId, artist, albumArtist, title, album, year, t } const outputTemplate = path.join(dir, `${trackPrefix}${safeTitle}.%(ext)s`); - // Use original artist name (with special chars) for all searches — stripping e.g. "N!GHT" → "NGHT" - // causes ytsearch to match "night" ambience videos instead of the artist. - // spawn() passes args directly without shell interpretation so special chars are safe. - const query = `${mainArtist} - ${title}`; + // Strip only Unicode symbol chars (☆ ★ ♥ etc.) for ytsearch — YouTube search chokes on them + // and returns 0 results. Keep ASCII punctuation (!&-) so e.g. "N!GHT" stays "N!GHT" rather + // than collapsing to "NGHT" which YouTube misreads as the word "night". + const searchArtist = mainArtist.replace(/\p{S}/gu, '').trim(); + const query = `${searchArtist} - ${title}`; const baseArgs = [ '--extract-audio',