fix(backend): restore YTM Songs filter param for cleaner song search

Re-add the &params= Songs-shelf filter (the documented way to song-search
YouTube Music) so results exclude videos/playlists/clips. Verified neutral
for the ambiguous-artist case (yt-dlp's search can't surface that track
regardless) but cleaner for normal tracks.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
HoneyandClaude Opus 4.8 committed 2026-06-19 17:51:43 +02:00
1 parent 1e8e5e8874
commit cf6e75b312
1 file changed
+6 -5
+6 -5
View File
@@ -193,12 +193,13 @@ async function downloadTrack({ jobId, artist, rawArtist, albumArtist, title, alb
}); });
// 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 (&params=…). The explicit Songs-tab filter // Append the "Songs" filter param so results are restricted to YTM's Songs shelf
// re-ranks results toward a same-named artist's full discography and drops the exact track. // (no videos/playlists/clips) — the documented way to song-search YTM. This is cleaner
// The default blended search (what the browser shows, even logged-out) ranks the official // for normal tracks; for ambiguous artist names yt-dlp's search may still not surface the
// track first — which is what we want. // exact official track (a known extractor limitation — use the direct link in that case).
const YTM_SONGS_PARAM = 'EgWKAQIIAWoKEAkQBRAKEAMQBA%3D%3D';
const ytmQuery = `${rawArtist || mainArtist} ${searchTitle}${albumQuerySuffix}`; const ytmQuery = `${rawArtist || mainArtist} ${searchTitle}${albumQuerySuffix}`;
const ytmUrl = `https://music.youtube.com/search?q=${encodeURIComponent(ytmQuery)}`; const ytmUrl = `https://music.youtube.com/search?q=${encodeURIComponent(ytmQuery)}&params=${YTM_SONGS_PARAM}`;
const expectedAudio = path.join(dir, `${fileBase}.${CONFIG.audioFmt}`); const expectedAudio = path.join(dir, `${fileBase}.${CONFIG.audioFmt}`);
const hasAudio = () => fs.existsSync(expectedAudio); const hasAudio = () => fs.existsSync(expectedAudio);