From ef019b9b9d55d6514fc92d0f543ba31d5cd18d9e Mon Sep 17 00:00:00 2001 From: Honey Date: Mon, 17 Aug 2026 12:20:52 +0200 Subject: [PATCH] fix(backend): direct-link download failure was reported as success MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The direct-URL (sourceUrl) path returned { success: true } even when no audio file was produced (e.g. YouTube 403 / bot check), so the job was marked "done/Fertig!" and web + Android both said the track was added. It now returns { failed: true } → the server sets status 'error' with a clear message, which both frontends already render as a failure. Search-cascade path was already correct. Co-Authored-By: Claude Opus 4.8 --- backend/lib/ytdlp.js | 5 ++++- backend/novasonic-server.js | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/backend/lib/ytdlp.js b/backend/lib/ytdlp.js index ecf1cf3..c8daefc 100644 --- a/backend/lib/ytdlp.js +++ b/backend/lib/ytdlp.js @@ -198,7 +198,10 @@ async function downloadTrack({ jobId, artist, rawArtist, albumArtist, title, alb log(jobId, `🔗 Direkter Download: ${sourceUrl}`); await spawnYtdlp([sourceUrl, '--no-playlist', ...baseArgs]); const audioFile = hasAudio() ? expectedAudio : null; - if (!audioFile) { log(jobId, '⚠️ Download fehlgeschlagen'); return { success: true, dir }; } + // Direct-link download failed (e.g. YouTube 403 / bot check) — must report FAILURE, not success. + // Previously returned { success: true }, so the job was marked "done/Fertig!" and the UI wrongly + // said the track was added. + if (!audioFile) { log(jobId, '⚠️ Download fehlgeschlagen'); return { success: false, failed: true, dir }; } return embedMetadata({ jobId, audioFile, dir, trackPrefix, safeTitle, rawArtist, artist, mainArtist, album, year, trackNum, totalTracks, discNum, discTotal, compilation, genre, artworkUrl, explicit, title: searchTitle }); } diff --git a/backend/novasonic-server.js b/backend/novasonic-server.js index f18ca28..35a27a7 100644 --- a/backend/novasonic-server.js +++ b/backend/novasonic-server.js @@ -657,6 +657,8 @@ app.post('/api/download', async (req, res) => { updateJob(jobId, { status: 'done', progress: 100, message: 'Bereits vorhanden – übersprungen', skipped: true }); } else if (result?.notFound) { updateJob(jobId, { status: 'error', message: 'Nicht eindeutig gefunden — bitte Direktlink im Importer nutzen' }); + } else if (result?.failed) { + updateJob(jobId, { status: 'error', message: 'Download fehlgeschlagen — YouTube hat den Abruf blockiert (403).' }); } else { updateJob(jobId, { status: 'done', progress: 100, message: 'Fertig!' }); }