// Single-track metadata resolver — the ONE place callers use to enrich a downloaded single. // Order: Deezer (artist-verified) → MusicBrainz (artist-verified) → nothing. // Returning {} is intentional and safe: the download then uses its clean fallback // (album_artist = song artist, album = "Singles", cover = source thumbnail, year/genre untouched). // // Both sources apply the SAME discipline — the artist must correspond — so a same-titled song by a // different artist can never contaminate album/cover/year again. const dz = require('./deezer'); const mb = require('./musicbrainz'); async function lookupTrackMeta(artist, title) { const d = await dz.lookupTrackMeta(artist, title).catch(() => ({})); if (d && d.album) return d; // Deezer matched (artist-verified) const m = await mb.lookupTrackMeta(artist, title).catch(() => ({})); if (m && m.album) return m; // MusicBrainz matched (artist-verified) return d || {}; // nothing convincing → clean fallback } module.exports = { lookupTrackMeta };