fix(backend): use YouTube Music search URL instead of invalid ytmsearch1: prefix

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 <noreply@anthropic.com>
This commit is contained in:
HoneyandClaude Sonnet 4.6 committed 2026-05-02 10:12:46 +02:00
1 parent 49a00b673b
commit ce8441d9ee
1 file changed
+4 -3
+4 -3
View File
@@ -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…');