fix: prevent 9-second downloads caused by short iTunes duration match

When iTunes enrichment returns a jingle/preview as the first result (e.g.
trackTimeMillis=9000), the yt-dlp duration filter becomes impossible
(duration > 30 & duration < 24), all filtered steps fail, and the final
unfiltered fallback downloads whatever YouTube returns first — often a
short clip.

Fix 1: spotify.js — only copy iTunes trackTimeMillis to durationMs when
it is > 30 seconds (genuine song, not a jingle or preview).

Fix 2: ytdlp.js — only enter the duration-filtered search branch when
durationMs > 30 000ms, so a corrupted short value silently falls back to
the unfiltered search path which still finds the correct full song.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
HoneyandClaude Sonnet 4.6 committed 2026-05-28 00:06:33 +02:00
1 parent 3db71c24a4
commit 2df5a54985
2 files changed
+4 -2

No files matched your search

+1 -1
View File
@@ -215,7 +215,7 @@ async function downloadTrack({ jobId, artist, rawArtist, albumArtist, title, alb
await spawnYtdlp([...urls, '--max-downloads', '1', ...mfArgs, ...baseArgs]);
};
if (durationMs) {
if (durationMs && durationMs > 30000) {
const durationSec = Math.round(durationMs / 1000);
const margin = Math.max(15, Math.round(durationSec * 0.15));
const dur = { min: Math.max(30, durationSec - margin), max: durationSec + margin };