A decentralized music tracking and discovery platform built on AT Protocol 馃幍
listenbrainz
spotify
atproto
lastfm
musicbrainz
scrobbling
1export function dedupeTracksKeepLyrics(tracks) {
2 const trackMap = new Map();
3
4 for (const track of tracks) {
5 const key = `${track.disc_number} - ${track.track_number}`;
6
7 if (!key) continue;
8
9 const existing = trackMap.get(key);
10
11 // If current has lyrics and either no existing or existing has no lyrics, replace it
12 if (!existing || (!existing.lyrics && track.lyrics)) {
13 trackMap.set(key, track);
14 }
15 }
16
17 return Array.from(trackMap.values());
18}