···11+import chalk from "chalk";
22+import { RockskyClient } from "client";
33+44+export async function albums(did, { skip, limit }) {
55+ const client = new RockskyClient();
66+ const albums = await client.getAlbums(did, { skip, limit });
77+ let rank = 1;
88+ for (const album of albums) {
99+ console.log(
1010+ `${rank} ${chalk.magenta(album.title)} ${album.artist} ${chalk.yellow(
1111+ album.play_count + " plays"
1212+ )}`
1313+ );
1414+ rank++;
1515+ }
1616+}
+16
src/cmd/artists.ts
···11+import chalk from "chalk";
22+import { RockskyClient } from "client";
33+44+export async function artists(did, { skip, limit }) {
55+ const client = new RockskyClient();
66+ const artists = await client.getArtists(did, { skip, limit });
77+ let rank = 1;
88+ for (const artist of artists) {
99+ console.log(
1010+ `${rank} ${chalk.magenta(artist.name)} ${chalk.yellow(
1111+ artist.play_count + " plays"
1212+ )}`
1313+ );
1414+ rank++;
1515+ }
1616+}
+16
src/cmd/tracks.ts
···11+import chalk from "chalk";
22+import { RockskyClient } from "client";
33+44+export async function tracks(did, { skip, limit }) {
55+ const client = new RockskyClient();
66+ const tracks = await client.getTracks(did, { skip, limit });
77+ let rank = 1;
88+ for (const track of tracks) {
99+ console.log(
1010+ `${rank} ${chalk.magenta(track.title)} ${track.artist} ${chalk.yellow(
1111+ track.play_count + " plays"
1212+ )}`
1313+ );
1414+ rank++;
1515+ }
1616+}
+25
src/index.ts
···11#!/usr/bin/env node
2233+import { albums } from "cmd/albums";
44+import { artists } from "cmd/artists";
35import { nowplaying } from "cmd/nowplaying";
46import { scrobbles } from "cmd/scrobbles";
57import { search } from "cmd/search";
68import { stats } from "cmd/stats";
99+import { tracks } from "cmd/tracks";
710import { whoami } from "cmd/whoami";
811import { Command } from "commander";
912import version from "../package.json" assert { type: "json" };
···61646265program
6366 .command("stats")
6767+ .option("-l, --limit <number>", "Number of results to limit")
6468 .argument("[did]", "The DID or handle of the user to get stats for.")
6569 .description("Get the user's listening stats.")
6670 .action(stats);
7171+7272+program
7373+ .command("artists")
7474+ .option("-l, --limit <number>", "Number of results to limit")
7575+ .argument("[did]", "The DID or handle of the user to get artists for.")
7676+ .description("Get the user's top artists.")
7777+ .action(artists);
7878+7979+program
8080+ .command("albums")
8181+ .option("-l, --limit <number>", "Number of results to limit")
8282+ .argument("[did]", "The DID or handle of the user to get albums for.")
8383+ .description("Get the user's top albums.")
8484+ .action(albums);
8585+8686+program
8787+ .command("tracks")
8888+ .option("-l, --limit <number>", "Number of results to limit")
8989+ .argument("[did]", "The DID or handle of the user to get tracks for.")
9090+ .description("Get the user's top tracks.")
9191+ .action(tracks);
67926893program.parse(process.argv);