refactor: remove dead code from backend and lib

- Remove unused spotifyClientId/spotifyClientSecret from config
- Remove AUDIO_EXTS from metadata exports (internal-only)
- Remove tryYtdlp wrapper in ytdlp.js (direct spawnYtdlp calls)
- Remove _spArtistName wrapper in server (direct _spAllArtists calls)
- Fix stale comment: primary resolver is SpotipyFree, not curl_cffi

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
HoneyandClaude Sonnet 4.6 committed 2026-05-12 18:18:50 +02:00
1 parent c36dbb3c94
commit 0f1e6ff531
4 files changed
+14 -22

No files matched your search

+10 -11
View File
@@ -108,7 +108,6 @@ async function downloadTrack({ jobId, artist, albumArtist, title, album, year, t
const ytmUrl = `https://music.youtube.com/search?q=${encodeURIComponent(ytmQuery)}&params=${YTM_SONGS_PARAM}`;
const expectedAudio = path.join(dir, `${trackPrefix}${safeTitle}.${CONFIG.audioFmt}`);
const hasAudio = () => fs.existsSync(expectedAudio);
const tryYtdlp = async (args) => { await spawnYtdlp(args); };
// Fetch YTM search result URLs as a flat list (no channel expansion) and return only
// actual video URLs (watch?v=…). This prevents yt-dlp from following an artist channel
@@ -152,7 +151,7 @@ async function downloadTrack({ jobId, artist, albumArtist, title, album, year, t
const tryYtmSearch = async (maxItems, mfArgs) => {
const urls = await getYtmVideoUrls(maxItems);
if (!urls.length) return;
await tryYtdlp([...urls, '--max-downloads', '1', ...mfArgs, ...baseArgs]);
await spawnYtdlp([...urls, '--max-downloads', '1', ...mfArgs, ...baseArgs]);
};
const variantFilter = buildVariantFilter(title);
@@ -189,7 +188,7 @@ async function downloadTrack({ jobId, artist, albumArtist, title, album, year, t
if (!hasAudio()) {
// 2. YT top-5 — strict: same filters including channel check
log(jobId, '⚠️ Kein YTM-Treffer — Fallback zu YouTube…');
await tryYtdlp([`ytsearch5:${query}`, ...PI_FILTERED, ...mf(dur, true, true), ...baseArgs]);
await spawnYtdlp([`ytsearch5:${query}`, ...PI_FILTERED, ...mf(dur, true, true), ...baseArgs]);
}
if (!hasAudio()) {
// 3. YTM top-10 — no channel check (label channels, etc.)
@@ -198,7 +197,7 @@ async function downloadTrack({ jobId, artist, albumArtist, title, album, year, t
}
if (!hasAudio()) {
// 4. YT top-10 — no channel check
await tryYtdlp([`ytsearch10:${query}`, ...PI_FILTERED_10, ...mf(dur, true), ...baseArgs]);
await spawnYtdlp([`ytsearch10:${query}`, ...PI_FILTERED_10, ...mf(dur, true), ...baseArgs]);
}
if (!hasAudio()) {
// 5. YTM top-5 — no duration check
@@ -207,7 +206,7 @@ async function downloadTrack({ jobId, artist, albumArtist, title, album, year, t
}
if (!hasAudio()) {
// 6. YT top-5 — no duration check
await tryYtdlp([`ytsearch5:${query}`, ...PI_FILTERED, ...mf(null, true), ...baseArgs]);
await spawnYtdlp([`ytsearch5:${query}`, ...PI_FILTERED, ...mf(null, true), ...baseArgs]);
}
if (!hasAudio()) {
// 7. YTM top-5 — title only (no variant filter)
@@ -216,7 +215,7 @@ async function downloadTrack({ jobId, artist, albumArtist, title, album, year, t
}
if (!hasAudio()) {
// 8. YT top-5 — title only
await tryYtdlp([`ytsearch5:${query}`, ...PI_FILTERED, ...mf(null, false), ...baseArgs]);
await spawnYtdlp([`ytsearch5:${query}`, ...PI_FILTERED, ...mf(null, false), ...baseArgs]);
}
if (!hasAudio()) {
// 9. YTM — no filter at all, take first video result
@@ -225,7 +224,7 @@ async function downloadTrack({ jobId, artist, albumArtist, title, album, year, t
}
if (!hasAudio()) {
// 10. YT — no filter
await tryYtdlp([`ytsearch1:${query}`, ...PI_UNFILTERED, ...baseArgs]);
await spawnYtdlp([`ytsearch1:${query}`, ...PI_UNFILTERED, ...baseArgs]);
}
} else {
log(jobId, `🔍 Suche YT Music: "${query}"`);
@@ -233,7 +232,7 @@ async function downloadTrack({ jobId, artist, albumArtist, title, album, year, t
await tryYtmSearch(5, mf(null, true, true));
if (!hasAudio()) {
// 2. YT top-5 — strict
await tryYtdlp([`ytsearch5:${query}`, ...PI_FILTERED, ...mf(null, true, true), ...baseArgs]);
await spawnYtdlp([`ytsearch5:${query}`, ...PI_FILTERED, ...mf(null, true, true), ...baseArgs]);
}
if (!hasAudio()) {
// 3. YTM top-5 — no channel check
@@ -241,7 +240,7 @@ async function downloadTrack({ jobId, artist, albumArtist, title, album, year, t
}
if (!hasAudio()) {
// 4. YT top-5 — no channel check
await tryYtdlp([`ytsearch5:${query}`, ...PI_FILTERED, ...mf(null, true), ...baseArgs]);
await spawnYtdlp([`ytsearch5:${query}`, ...PI_FILTERED, ...mf(null, true), ...baseArgs]);
}
if (!hasAudio()) {
// 5. YTM top-5 — title only
@@ -250,7 +249,7 @@ async function downloadTrack({ jobId, artist, albumArtist, title, album, year, t
}
if (!hasAudio()) {
// 6. YT top-5 — title only
await tryYtdlp([`ytsearch5:${query}`, ...PI_FILTERED, ...mf(null, false), ...baseArgs]);
await spawnYtdlp([`ytsearch5:${query}`, ...PI_FILTERED, ...mf(null, false), ...baseArgs]);
}
if (!hasAudio()) {
// 7. YTM — first video result, no filter
@@ -259,7 +258,7 @@ async function downloadTrack({ jobId, artist, albumArtist, title, album, year, t
}
if (!hasAudio()) {
// 8. YT — no filter
await tryYtdlp([`ytsearch1:${query}`, ...PI_UNFILTERED, ...baseArgs]);
await spawnYtdlp([`ytsearch1:${query}`, ...PI_UNFILTERED, ...baseArgs]);
}
}