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

Add --dry-run option to scrobble command

Pass dryRun through the scrobble action into publishScrobble and short-
circuit publishing to log-only when set

+13 -2
+6 -2
apps/cli/src/cmd/scrobble.ts
··· 2 2 import { logger } from "logger"; 3 3 import { publishScrobble } from "scrobble"; 4 4 5 - export async function scrobble(track: string, artist: string, { timestamp }) { 5 + export async function scrobble( 6 + track: string, 7 + artist: string, 8 + { timestamp, dryRun }, 9 + ) { 6 10 const match = await matchTrack(track, artist); 7 - const success = await publishScrobble(match, timestamp); 11 + const success = await publishScrobble(match, timestamp, dryRun); 8 12 9 13 if (!success) { 10 14 process.exit(1);
+1
apps/cli/src/index.ts
··· 125 125 .argument("<track>", "the title of the track") 126 126 .argument("<artist>", "the artist of the track") 127 127 .option("-t, --timestamp <timestamp>", "the timestamp of the scrobble") 128 + .option("-d, --dry-run", "simulate the scrobble without actually sending it") 128 129 .description("scrobble a track to your profile.") 129 130 .action(scrobble); 130 131
+6
apps/cli/src/scrobble.ts
··· 21 21 export async function publishScrobble( 22 22 track: MatchTrackResult, 23 23 timestamp?: number, 24 + dryRun?: boolean, 24 25 ) { 25 26 const [did, handle] = await getDidAndHandle(); 26 27 const agent: Agent = await createAgent(did, handle); ··· 48 49 } 49 50 50 51 logger.info`${handle} Publishing scrobble for ${track.title} by ${track.artist} at ${timestamp ? dayjs.unix(timestamp).format("YYYY-MM-DD HH:mm:ss") : dayjs().format("YYYY-MM-DD HH:mm:ss")}`; 52 + 53 + if (dryRun) { 54 + logger.info`${handle} Dry run: Skipping publishing scrobble for ${track.title} by ${track.artist} at ${timestamp ? dayjs.unix(timestamp).format("YYYY-MM-DD HH:mm:ss") : dayjs().format("YYYY-MM-DD HH:mm:ss")}`; 55 + return true; 56 + } 51 57 52 58 const existingTrack = await ctx.db 53 59 .select()