From c4e4c8c09056d10b6e2ea347aa476b9bdb2346db Mon Sep 17 00:00:00 2001 From: Honey Date: Fri, 19 Jun 2026 11:06:00 +0200 Subject: [PATCH] fix(backend): use space (not dash) between artist and title in search query MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit "MINA - recognize" skewed YTM ranking toward a same-named artist's full discography, so the actual track (qNffDItRUeo) never appeared in results. "MINA recognize" — matching how users type in the YTM search box — ranks the exact official track first. Co-Authored-By: Claude Opus 4.8 --- backend/lib/ytdlp.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/backend/lib/ytdlp.js b/backend/lib/ytdlp.js index 41676b9..1a0a98d 100644 --- a/backend/lib/ytdlp.js +++ b/backend/lib/ytdlp.js @@ -145,7 +145,10 @@ async function downloadTrack({ jobId, artist, rawArtist, albumArtist, title, alb // For Western tracks, artist + title + duration matching is sufficient (matches spotdl behaviour). const albumQuerySuffix = hasJpTitle && albumWords ? ' ' + albumWords : ''; - const query = `${ytmArtist} - ${searchTitle}${albumQuerySuffix}`; + // Use a space (not " - ") between artist and title: this matches how users type + // in the YTM search box and ranks the exact official track first. A dash skews + // YTM ranking toward a same-named artist's full discography. + const query = `${ytmArtist} ${searchTitle}${albumQuerySuffix}`; const baseArgs = [ '--extract-audio', @@ -188,7 +191,7 @@ async function downloadTrack({ jobId, artist, rawArtist, albumArtist, title, alb const YTM_SONGS_PARAM = 'EgWKAQIIAWoKEAkQBRAKEAMQBA%3D%3D'; // Use original (raw) artist for YTM URL — better ranking since channel is in original language - const ytmQuery = `${rawArtist || mainArtist} - ${searchTitle}${albumQuerySuffix}`; + const ytmQuery = `${rawArtist || mainArtist} ${searchTitle}${albumQuerySuffix}`; const ytmUrl = `https://music.youtube.com/search?q=${encodeURIComponent(ytmQuery)}¶ms=${YTM_SONGS_PARAM}`; const expectedAudio = path.join(dir, `${fileBase}.${CONFIG.audioFmt}`); const hasAudio = () => fs.existsSync(expectedAudio);