diff --git a/backend/lib/ytdlp.js b/backend/lib/ytdlp.js index 1a0a98d..1d2108d 100644 --- a/backend/lib/ytdlp.js +++ b/backend/lib/ytdlp.js @@ -189,10 +189,13 @@ 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 + // Use original (raw) artist for YTM URL — better ranking since channel is in original language. + // NOTE: do NOT append the "Songs" filter param (¶ms=…). The explicit Songs-tab filter + // re-ranks results toward a same-named artist's full discography and drops the exact track. + // The default blended search (what the browser shows, even logged-out) ranks the official + // track first — which is what we want. const ytmQuery = `${rawArtist || mainArtist} ${searchTitle}${albumQuerySuffix}`; - const ytmUrl = `https://music.youtube.com/search?q=${encodeURIComponent(ytmQuery)}¶ms=${YTM_SONGS_PARAM}`; + const ytmUrl = `https://music.youtube.com/search?q=${encodeURIComponent(ytmQuery)}`; const expectedAudio = path.join(dir, `${fileBase}.${CONFIG.audioFmt}`); const hasAudio = () => fs.existsSync(expectedAudio);