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…');