A decentralized music tracking and discovery platform built on AT Protocol 🎵

fix: improve error handling in publishPlayingNow function

+2 -10
+2 -10
apps/api/src/tealfm/index.ts
··· 14 14 collection: "fm.teal.alpha.feed.play", 15 15 limit, 16 16 }); 17 + console.log("Recent plays:"); 18 + console.log(chalk.cyan(JSON.stringify(res.data.records, null, 2))); 17 19 return res.data.records; 18 20 } 19 21 ··· 26 28 // wait 60 seconds to ensure the track is actually being played 27 29 await new Promise((resolve) => setTimeout(resolve, 60000)); 28 30 const recentPlays = await getRecentPlays(agent, 5); 29 - console.log("Recent plays:"); 30 - console.log(JSON.stringify(recentPlays, null, 2)); 31 31 // Check if the track was played in the last 5 plays (verify by MBID and timestamp to avoid duplicates) 32 32 const alreadyPlayed = recentPlays.some((play) => { 33 33 const record = Play.isRecord(play.value) ? play.value : null; 34 - console.log( 35 - "Checking recent play:", 36 - record?.recordingMbId, 37 - track.trackMBID, 38 - record?.playedTime, 39 - track.timestamp, 40 - record?.submissionClientAgent 41 - ); 42 34 return ( 43 35 record?.recordingMbId === track.trackMBID && 44 36 // diff in seconds less than 60