A decentralized music tracking and discovery platform built on AT Protocol 🎵 rocksky.app
spotify atproto lastfm musicbrainz scrobbling listenbrainz
98
fork

Configure Feed

Select the types of activity you want to include in your feed.

Allow small duration delta when checking repeats

Treat durations within 4 seconds as equivalent when determining recent
plays to avoid false duplicates. Also clean up formatting and add
trailing commas to function parameters for consistency.

+11 -9
+11 -9
apps/api/src/tealfm/index.ts
··· 20 20 async function publishPlayingNow( 21 21 agent: Agent, 22 22 track: MusicbrainzTrack, 23 - duration: number 23 + duration: number, 24 24 ) { 25 25 try { 26 26 // wait 60 seconds to ensure the track is actually being played ··· 31 31 const record = Play.isRecord(play.value) ? play.value : null; 32 32 return ( 33 33 (record?.recordingMbId === track.trackMBID || 34 - (record?.duration === duration && 34 + (Math.abs(record?.duration - duration) < 4 && 35 35 record?.trackName === track.name)) && 36 36 // diff in seconds less than 60 37 37 Math.abs( 38 - new Date(record.playedTime).getTime() - 39 - new Date(track.timestamp).getTime() 40 - ) < 60000 38 + new Date(record.playedTime).getTime() - 39 + new Date(track.timestamp).getTime(), 40 + ) < 60000 41 41 ); 42 42 }); 43 43 if (alreadyPlayed) { 44 44 console.log( 45 - `Track ${chalk.cyan(track.name)} by ${chalk.cyan( 46 - track.artist.map((a) => a.name).join(", ") 47 - )} already played recently. Skipping...` 45 + `Track ${chalk.cyan(track.name)} by ${ 46 + chalk.cyan( 47 + track.artist.map((a) => a.name).join(", "), 48 + ) 49 + } already played recently. Skipping...`, 48 50 ); 49 51 return; 50 52 } ··· 90 92 async function publishStatus( 91 93 agent: Agent, 92 94 track: MusicbrainzTrack, 93 - duration: number 95 + duration: number, 94 96 ) { 95 97 const item: PlayView = { 96 98 trackName: track.name,