From ce8441d9ee114358577e76aaf264cc17c779e732 Mon Sep 17 00:00:00 2001 From: Honey Date: Sat, 2 May 2026 10:12:46 +0200 Subject: [PATCH] fix(backend): use YouTube Music search URL instead of invalid ytmsearch1: prefix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ytmsearch1: is not a valid yt-dlp scheme — use full music.youtube.com URL with --playlist-items 1. Co-Authored-By: Claude Sonnet 4.6 --- backend/novasonic-server.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/backend/novasonic-server.js b/backend/novasonic-server.js index a9d02ff..038fb6a 100644 --- a/backend/novasonic-server.js +++ b/backend/novasonic-server.js @@ -216,6 +216,7 @@ async function downloadTrack({ jobId, artist, albumArtist, title, album, year, t }); const hasAudio = () => fs.readdirSync(dir).some(f => AUDIO_EXTS.some(e => f.endsWith(`.${e}`))); + const ytmUrl = `https://music.youtube.com/search?q=${encodeURIComponent(query)}`; if (durationMs) { const durationSec = Math.round(durationMs / 1000); @@ -224,11 +225,11 @@ async function downloadTrack({ jobId, artist, albumArtist, title, album, year, t const durFilter = ['--match-filter', `duration > ${minDur} & duration < ${maxDur} & !is_live`]; log(jobId, `🔍 Suche YT Music (~${durationSec}s): "${query}"`); - await spawnYtdlp([`ytmsearch1:${query}`, ...durFilter, ...baseArgs]); + await spawnYtdlp([ytmUrl, '--playlist-items', '1', ...durFilter, ...baseArgs]); if (!hasAudio()) { log(jobId, '⚠️ Kein YT-Music-Treffer im Dauerbereich — Suche ohne Filter…'); - await spawnYtdlp([`ytmsearch1:${query}`, ...baseArgs]); + await spawnYtdlp([ytmUrl, '--playlist-items', '1', ...baseArgs]); } if (!hasAudio()) { log(jobId, '⚠️ Kein YT-Music-Treffer — Fallback zu YouTube…'); @@ -240,7 +241,7 @@ async function downloadTrack({ jobId, artist, albumArtist, title, album, year, t } } else { log(jobId, `🔍 Suche YT Music: "${query}"`); - await spawnYtdlp([`ytmsearch1:${query}`, ...baseArgs]); + await spawnYtdlp([ytmUrl, '--playlist-items', '1', ...baseArgs]); if (!hasAudio()) { log(jobId, '⚠️ Kein YT-Music-Treffer — Fallback zu YouTube…');