forked from
rocksky.app/rocksky
A decentralized music tracking and discovery platform built on AT Protocol 馃幍
1import chalk from "chalk";
2import { RockskyClient } from "client";
3import dayjs from "dayjs";
4import relative from "dayjs/plugin/relativeTime.js";
5
6dayjs.extend(relative);
7
8export async function scrobbles(did, { skip, limit }) {
9 const client = new RockskyClient();
10 const scrobbles = await client.scrobbles(did, { skip, limit });
11
12 for (const scrobble of scrobbles) {
13 if (did) {
14 console.log(
15 `${chalk.bold.magenta(scrobble.title)} ${
16 scrobble.artist
17 } ${chalk.yellow(dayjs(scrobble.created_at + "Z").fromNow())}`
18 );
19 continue;
20 }
21 const handle = `@${scrobble.user}`;
22 console.log(
23 `${chalk.italic.magentaBright(
24 handle
25 )} is listening to ${chalk.bold.magenta(scrobble.title)} ${
26 scrobble.artist
27 } ${chalk.yellow(dayjs(scrobble.date).fromNow())}`
28 );
29 }
30}