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:
1 parent
49a00b673b
commit
ce8441d9ee
1 file changed
+4
-3
@@ -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 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) {
|
if (durationMs) {
|
||||||
const durationSec = Math.round(durationMs / 1000);
|
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`];
|
const durFilter = ['--match-filter', `duration > ${minDur} & duration < ${maxDur} & !is_live`];
|
||||||
|
|
||||||
log(jobId, `🔍 Suche YT Music (~${durationSec}s): "${query}"`);
|
log(jobId, `🔍 Suche YT Music (~${durationSec}s): "${query}"`);
|
||||||
await spawnYtdlp([`ytmsearch1:${query}`, ...durFilter, ...baseArgs]);
|
await spawnYtdlp([ytmUrl, '--playlist-items', '1', ...durFilter, ...baseArgs]);
|
||||||
|
|
||||||
if (!hasAudio()) {
|
if (!hasAudio()) {
|
||||||
log(jobId, '⚠️ Kein YT-Music-Treffer im Dauerbereich — Suche ohne Filter…');
|
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()) {
|
if (!hasAudio()) {
|
||||||
log(jobId, '⚠️ Kein YT-Music-Treffer — Fallback zu YouTube…');
|
log(jobId, '⚠️ Kein YT-Music-Treffer — Fallback zu YouTube…');
|
||||||
@@ -240,7 +241,7 @@ async function downloadTrack({ jobId, artist, albumArtist, title, album, year, t
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log(jobId, `🔍 Suche YT Music: "${query}"`);
|
log(jobId, `🔍 Suche YT Music: "${query}"`);
|
||||||
await spawnYtdlp([`ytmsearch1:${query}`, ...baseArgs]);
|
await spawnYtdlp([ytmUrl, '--playlist-items', '1', ...baseArgs]);
|
||||||
|
|
||||||
if (!hasAudio()) {
|
if (!hasAudio()) {
|
||||||
log(jobId, '⚠️ Kein YT-Music-Treffer — Fallback zu YouTube…');
|
log(jobId, '⚠️ Kein YT-Music-Treffer — Fallback zu YouTube…');
|
||||||
|
|||||||
Reference in new issue
Block a user