From 2d1c9029c5b48d6b1d992610737b7b6582227760 Mon Sep 17 00:00:00 2001 From: Honey Date: Sat, 2 May 2026 15:38:35 +0200 Subject: [PATCH] fix: add YTM 'Songs only' filter param to search URL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Without ¶ms=EgWKAQII..., yt-dlp gets a mixed feed of videos, channels and playlists alongside tracks — same query that shows the correct song first in the browser "Titel" tab returned nursery rhyme videos and unrelated channels. This param is YTM's internal 'Songs' filter (equivalent to clicking the Titel tab). Co-Authored-By: Claude Sonnet 4.6 --- backend/novasonic-server.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/novasonic-server.js b/backend/novasonic-server.js index 9c1ff12..02c2fa7 100644 --- a/backend/novasonic-server.js +++ b/backend/novasonic-server.js @@ -274,7 +274,10 @@ async function downloadTrack({ jobId, artist, albumArtist, title, album, year, t ); }); - const ytmUrl = `https://music.youtube.com/search?q=${encodeURIComponent(query)}`; + // ¶ms= is YTM's "Songs only" filter (same as clicking "Titel" tab in the browser). + // Without it yt-dlp gets a mixed feed of videos, channels, and playlists as well. + const YTM_SONGS_PARAM = 'EgWKAQIIAWoKEAkQBRAKEAMQBA%3D%3D'; + const ytmUrl = `https://music.youtube.com/search?q=${encodeURIComponent(query)}¶ms=${YTM_SONGS_PARAM}`; // Snapshot files already in dir before we start — so hasAudio() only detects NEW files // from the current download attempt, not pre-existing files from parallel jobs. let snapBefore = new Set(fs.readdirSync(dir));