···1+import chalk from "chalk";
2+import { RockskyClient } from "client";
3+4+export async function albums(did, { skip, limit }) {
5+ const client = new RockskyClient();
6+ const albums = await client.getAlbums(did, { skip, limit });
7+ let rank = 1;
8+ for (const album of albums) {
9+ console.log(
10+ `${rank} ${chalk.magenta(album.title)} ${album.artist} ${chalk.yellow(
11+ album.play_count + " plays"
12+ )}`
13+ );
14+ rank++;
15+ }
16+}
+16
src/cmd/artists.ts
···0000000000000000
···1+import chalk from "chalk";
2+import { RockskyClient } from "client";
3+4+export async function artists(did, { skip, limit }) {
5+ const client = new RockskyClient();
6+ const artists = await client.getArtists(did, { skip, limit });
7+ let rank = 1;
8+ for (const artist of artists) {
9+ console.log(
10+ `${rank} ${chalk.magenta(artist.name)} ${chalk.yellow(
11+ artist.play_count + " plays"
12+ )}`
13+ );
14+ rank++;
15+ }
16+}
+16
src/cmd/tracks.ts
···0000000000000000
···1+import chalk from "chalk";
2+import { RockskyClient } from "client";
3+4+export async function tracks(did, { skip, limit }) {
5+ const client = new RockskyClient();
6+ const tracks = await client.getTracks(did, { skip, limit });
7+ let rank = 1;
8+ for (const track of tracks) {
9+ console.log(
10+ `${rank} ${chalk.magenta(track.title)} ${track.artist} ${chalk.yellow(
11+ track.play_count + " plays"
12+ )}`
13+ );
14+ rank++;
15+ }
16+}
+25
src/index.ts
···1#!/usr/bin/env node
2003import { nowplaying } from "cmd/nowplaying";
4import { scrobbles } from "cmd/scrobbles";
5import { search } from "cmd/search";
6import { stats } from "cmd/stats";
07import { whoami } from "cmd/whoami";
8import { Command } from "commander";
9import version from "../package.json" assert { type: "json" };
···6162program
63 .command("stats")
064 .argument("[did]", "The DID or handle of the user to get stats for.")
65 .description("Get the user's listening stats.")
66 .action(stats);
0000000000000000000006768program.parse(process.argv);
···1#!/usr/bin/env node
23+import { albums } from "cmd/albums";
4+import { artists } from "cmd/artists";
5import { nowplaying } from "cmd/nowplaying";
6import { scrobbles } from "cmd/scrobbles";
7import { search } from "cmd/search";
8import { stats } from "cmd/stats";
9+import { tracks } from "cmd/tracks";
10import { whoami } from "cmd/whoami";
11import { Command } from "commander";
12import version from "../package.json" assert { type: "json" };
···6465program
66 .command("stats")
67+ .option("-l, --limit <number>", "Number of results to limit")
68 .argument("[did]", "The DID or handle of the user to get stats for.")
69 .description("Get the user's listening stats.")
70 .action(stats);
71+72+program
73+ .command("artists")
74+ .option("-l, --limit <number>", "Number of results to limit")
75+ .argument("[did]", "The DID or handle of the user to get artists for.")
76+ .description("Get the user's top artists.")
77+ .action(artists);
78+79+program
80+ .command("albums")
81+ .option("-l, --limit <number>", "Number of results to limit")
82+ .argument("[did]", "The DID or handle of the user to get albums for.")
83+ .description("Get the user's top albums.")
84+ .action(albums);
85+86+program
87+ .command("tracks")
88+ .option("-l, --limit <number>", "Number of results to limit")
89+ .argument("[did]", "The DID or handle of the user to get tracks for.")
90+ .description("Get the user's top tracks.")
91+ .action(tracks);
9293program.parse(process.argv);