@kud/qobuz-cli 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/index.js +241 -72
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
- **Fast search & metadata** — search albums, tracks, and artists; inspect album, artist, and track details.
|
|
16
16
|
- **Library & playlists** — list, add, and remove favourites; list, show, create, and edit playlists.
|
|
17
|
+
- **Collection stats** — `qobuz stats` shows your genre mix, hi-res ratio, and top artists/labels from the local desktop library.
|
|
17
18
|
- **Media-key playback control** — `play`, `next`, `previous`, `forward`, and `rewind` drive the Qobuz desktop app via real media keys (macOS, requires Accessibility permission).
|
|
18
19
|
- **Quick open & copy** — `open` deep-links straight into the Qobuz app; `url` (alias `copy-url`) copies a link to the clipboard — bare `qobuz url` copies the **currently-playing** track.
|
|
19
20
|
- **Secure login** — stores a browser-borrowed token in the macOS Keychain; no password handling.
|
|
@@ -32,6 +33,7 @@ $ qobuz search "radiohead"
|
|
|
32
33
|
$ qobuz album 0634904032432
|
|
33
34
|
$ qobuz fav list
|
|
34
35
|
$ qobuz playlist create "Focus"
|
|
36
|
+
$ qobuz stats # collection analytics from the desktop library
|
|
35
37
|
$ qobuz play # toggle play/pause in Qobuz
|
|
36
38
|
$ qobuz next # skip track (also: previous, forward, rewind)
|
|
37
39
|
$ qobuz open album 0634904032432 # open in the Qobuz app
|
|
@@ -40,7 +42,7 @@ $ qobuz url album 0634904032432 # copy a specific item's deep link
|
|
|
40
42
|
$ qobuz url --plain # print the bare URL (no clipboard) for scripting
|
|
41
43
|
```
|
|
42
44
|
|
|
43
|
-
Full command set: `login`, `logout`, `search`, `album`, `artist`, `track`, `similar`, `fav` (list/add/remove), `playlist` (list/show/create/add/remove), `url` / `copy-url`, `open`, `play`, `next`, `previous` / `prev`, `forward` / `ff`, `rewind` / `rew`.
|
|
45
|
+
Full command set: `login`, `logout`, `search`, `album`, `artist`, `track`, `similar`, `fav` (list/add/remove), `playlist` (list/show/create/add/remove), `stats`, `url` / `copy-url`, `open`, `play`, `next`, `previous` / `prev`, `forward` / `ff`, `rewind` / `rew`.
|
|
44
46
|
|
|
45
47
|
> **macOS note** — playback commands (`play`, `next`, `previous`, `forward`, `rewind`) use real media keys and require Accessibility permission granted to your terminal. The first playback command compiles a small Swift helper via `swiftc`.
|
|
46
48
|
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
|
-
import { defineCommand as
|
|
4
|
+
import { defineCommand as defineCommand14, runMain } from "citty";
|
|
5
5
|
|
|
6
6
|
// src/help.ts
|
|
7
7
|
import { renderUsage } from "citty";
|
|
@@ -58,6 +58,41 @@ var deepLinkFor = (client, type, id) => {
|
|
|
58
58
|
return builders[type]?.(id);
|
|
59
59
|
};
|
|
60
60
|
|
|
61
|
+
// src/ui.ts
|
|
62
|
+
var ESC2 = String.fromCharCode(27);
|
|
63
|
+
var colour = process.stdout.isTTY;
|
|
64
|
+
var ansi = new RegExp(`${ESC2}\\[[0-9;]*m`, "g");
|
|
65
|
+
var style = (open2, close) => (text) => colour ? `${ESC2}[${open2}m${text}${ESC2}[${close}m` : text;
|
|
66
|
+
var bold2 = style("1", "22");
|
|
67
|
+
var dim = style("2", "22");
|
|
68
|
+
var accent = style("36", "39");
|
|
69
|
+
var muted = style("90", "39");
|
|
70
|
+
var good = style("32", "39");
|
|
71
|
+
var heading = (text) => console.log(`
|
|
72
|
+
${bold2(text)}`);
|
|
73
|
+
var success = (text) => console.log(`${good("\u2713")} ${text}`);
|
|
74
|
+
var link = (url2) => `${dim("\u2197")} ${accent(url2)}`;
|
|
75
|
+
var visibleWidth = (text) => text.replace(ansi, "").length;
|
|
76
|
+
var columns = (rows, aligns = []) => {
|
|
77
|
+
const colCount = Math.max(0, ...rows.map((row) => row.length));
|
|
78
|
+
const widths = Array.from(
|
|
79
|
+
{ length: colCount },
|
|
80
|
+
(_, i) => Math.max(0, ...rows.map((row) => visibleWidth(row[i] ?? "")))
|
|
81
|
+
);
|
|
82
|
+
const pad = (cell, i) => {
|
|
83
|
+
const gap = " ".repeat(Math.max(0, (widths[i] ?? 0) - visibleWidth(cell)));
|
|
84
|
+
return aligns[i] === "right" ? gap + cell : cell + gap;
|
|
85
|
+
};
|
|
86
|
+
return rows.map((row) => ` ${row.map(pad).join(" ").trimEnd()}`).join("\n");
|
|
87
|
+
};
|
|
88
|
+
var BLOCKS = ["", "\u258F", "\u258E", "\u258D", "\u258C", "\u258B", "\u258A", "\u2589"];
|
|
89
|
+
var bar = (value, max, width = 22) => {
|
|
90
|
+
const units = max > 0 ? value / max * width : 0;
|
|
91
|
+
const full = Math.floor(units);
|
|
92
|
+
const partial = BLOCKS[Math.round((units - full) * 8)] ?? "";
|
|
93
|
+
return `${"\u2588".repeat(full)}${partial}`.padEnd(width);
|
|
94
|
+
};
|
|
95
|
+
|
|
61
96
|
// src/commands/album.ts
|
|
62
97
|
var album = defineCommand({
|
|
63
98
|
meta: { name: "album", description: "Show album details" },
|
|
@@ -67,12 +102,16 @@ var album = defineCommand({
|
|
|
67
102
|
run: async ({ args: args2 }) => {
|
|
68
103
|
const client = await connect();
|
|
69
104
|
const album2 = await client.albums.get(args2.id);
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
);
|
|
75
|
-
console.log(`
|
|
105
|
+
const meta = [
|
|
106
|
+
`${album2.tracksCount ?? "?"} tracks`,
|
|
107
|
+
`released ${album2.releaseDate ?? "?"}`,
|
|
108
|
+
album2.hires ? "Hi-Res" : void 0
|
|
109
|
+
].filter(Boolean).join(" \xB7 ");
|
|
110
|
+
console.log(`
|
|
111
|
+
${bold2(`\u{1F4BF} ${album2.title}`)}`);
|
|
112
|
+
console.log(` ${dim(`by ${album2.artist?.name ?? "?"}`)}`);
|
|
113
|
+
console.log(` ${dim(meta)}`);
|
|
114
|
+
console.log(` ${link(client.deepLink.album(album2.id))}`);
|
|
76
115
|
}
|
|
77
116
|
});
|
|
78
117
|
|
|
@@ -86,10 +125,11 @@ var artist = defineCommand2({
|
|
|
86
125
|
run: async ({ args: args2 }) => {
|
|
87
126
|
const client = await connect();
|
|
88
127
|
const artist2 = await client.artists.get(Number(args2.id));
|
|
89
|
-
console.log(
|
|
128
|
+
console.log(`
|
|
129
|
+
${bold2(`\u{1F3A4} ${artist2.name}`)}`);
|
|
90
130
|
if (artist2.albumsCount !== void 0)
|
|
91
|
-
console.log(`${artist2.albumsCount} albums`);
|
|
92
|
-
console.log(`
|
|
131
|
+
console.log(` ${dim(`${artist2.albumsCount} albums`)}`);
|
|
132
|
+
console.log(` ${link(client.deepLink.artist(artist2.id))}`);
|
|
93
133
|
}
|
|
94
134
|
});
|
|
95
135
|
|
|
@@ -107,16 +147,41 @@ var list = defineCommand3({
|
|
|
107
147
|
run: async ({ args: args2 }) => {
|
|
108
148
|
const client = await connect();
|
|
109
149
|
const favourites = await client.favourites.list(args2.type);
|
|
110
|
-
|
|
150
|
+
if (favourites.albums.length) {
|
|
151
|
+
heading("\u{1F4BF} Albums");
|
|
111
152
|
console.log(
|
|
112
|
-
|
|
153
|
+
columns(
|
|
154
|
+
favourites.albums.map((album2) => [
|
|
155
|
+
accent(album2.title),
|
|
156
|
+
dim(album2.artist?.name ?? "?"),
|
|
157
|
+
muted(String(album2.id))
|
|
158
|
+
])
|
|
159
|
+
)
|
|
113
160
|
);
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
161
|
+
}
|
|
162
|
+
if (favourites.artists.length) {
|
|
163
|
+
heading("\u{1F3A4} Artists");
|
|
164
|
+
console.log(
|
|
165
|
+
columns(
|
|
166
|
+
favourites.artists.map((artist2) => [
|
|
167
|
+
accent(artist2.name),
|
|
168
|
+
muted(String(artist2.id))
|
|
169
|
+
])
|
|
170
|
+
)
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
if (favourites.tracks.length) {
|
|
174
|
+
heading("\u{1F3B5} Tracks");
|
|
117
175
|
console.log(
|
|
118
|
-
|
|
176
|
+
columns(
|
|
177
|
+
favourites.tracks.map((track2) => [
|
|
178
|
+
accent(track2.title),
|
|
179
|
+
dim(track2.artist?.name ?? "?"),
|
|
180
|
+
muted(String(track2.id))
|
|
181
|
+
])
|
|
182
|
+
)
|
|
119
183
|
);
|
|
184
|
+
}
|
|
120
185
|
}
|
|
121
186
|
});
|
|
122
187
|
var add = defineCommand3({
|
|
@@ -136,7 +201,7 @@ var add = defineCommand3({
|
|
|
136
201
|
run: async ({ args: args2 }) => {
|
|
137
202
|
const client = await connect();
|
|
138
203
|
await client.favourites.add(args2.type, args2.id);
|
|
139
|
-
|
|
204
|
+
success(`added ${args2.type} ${args2.id} to favourites`);
|
|
140
205
|
}
|
|
141
206
|
});
|
|
142
207
|
var remove = defineCommand3({
|
|
@@ -156,7 +221,7 @@ var remove = defineCommand3({
|
|
|
156
221
|
run: async ({ args: args2 }) => {
|
|
157
222
|
const client = await connect();
|
|
158
223
|
await client.favourites.remove(args2.type, args2.id);
|
|
159
|
-
|
|
224
|
+
success(`removed ${args2.type} ${args2.id} from favourites`);
|
|
160
225
|
}
|
|
161
226
|
});
|
|
162
227
|
var fav = defineCommand3({
|
|
@@ -184,16 +249,16 @@ var createPrompts = () => {
|
|
|
184
249
|
(resolve) => rl.question(question, (answer) => resolve(answer.trim()))
|
|
185
250
|
);
|
|
186
251
|
const askHidden = (question) => new Promise((resolve) => {
|
|
187
|
-
let
|
|
252
|
+
let muted2 = false;
|
|
188
253
|
rl._writeToOutput = (chunk) => {
|
|
189
|
-
if (!
|
|
254
|
+
if (!muted2) process.stdout.write(chunk);
|
|
190
255
|
};
|
|
191
256
|
rl.question(question, (answer) => {
|
|
192
257
|
rl._writeToOutput = (chunk) => process.stdout.write(chunk);
|
|
193
258
|
process.stdout.write("\n");
|
|
194
259
|
resolve(answer);
|
|
195
260
|
});
|
|
196
|
-
|
|
261
|
+
muted2 = true;
|
|
197
262
|
});
|
|
198
263
|
return { ask, askHidden, close: () => rl.close() };
|
|
199
264
|
};
|
|
@@ -217,8 +282,8 @@ var copyToClipboard = async (text) => {
|
|
|
217
282
|
};
|
|
218
283
|
var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
219
284
|
var countdownAndOpen = async (url2, seconds = 3) => {
|
|
220
|
-
for (const
|
|
221
|
-
process.stdout.write(`\r Opening ${url2} in ${
|
|
285
|
+
for (const n2 of Array.from({ length: seconds }, (_, i) => seconds - i)) {
|
|
286
|
+
process.stdout.write(`\r Opening ${url2} in ${n2}\u2026 `);
|
|
222
287
|
await sleep(1e3);
|
|
223
288
|
}
|
|
224
289
|
process.stdout.write(`\r Opening ${url2} now.${" ".repeat(20)}
|
|
@@ -301,13 +366,13 @@ var open = defineCommand6({
|
|
|
301
366
|
},
|
|
302
367
|
run: async ({ args: args2 }) => {
|
|
303
368
|
const client = await connect();
|
|
304
|
-
const
|
|
305
|
-
if (!
|
|
369
|
+
const link2 = deepLinkFor(client, args2.type, args2.id);
|
|
370
|
+
if (!link2) {
|
|
306
371
|
console.error("type must be one of: album, track, playlist, artist");
|
|
307
372
|
process.exit(1);
|
|
308
373
|
}
|
|
309
|
-
console.log(`opening ${
|
|
310
|
-
await openUrl(
|
|
374
|
+
console.log(`opening ${link2}`);
|
|
375
|
+
await openUrl(link2);
|
|
311
376
|
}
|
|
312
377
|
});
|
|
313
378
|
|
|
@@ -390,11 +455,17 @@ var list2 = defineCommand8({
|
|
|
390
455
|
run: async () => {
|
|
391
456
|
const client = await connect();
|
|
392
457
|
const playlists = await client.playlists.listForUser();
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
458
|
+
if (!playlists.length) return;
|
|
459
|
+
heading("\u{1F4DD} Playlists");
|
|
460
|
+
console.log(
|
|
461
|
+
columns(
|
|
462
|
+
playlists.map((playlist2) => [
|
|
463
|
+
accent(playlist2.name),
|
|
464
|
+
dim(`${playlist2.tracksCount ?? 0} tracks`),
|
|
465
|
+
muted(String(playlist2.id))
|
|
466
|
+
])
|
|
467
|
+
)
|
|
468
|
+
);
|
|
398
469
|
}
|
|
399
470
|
});
|
|
400
471
|
var show = defineCommand8({
|
|
@@ -405,9 +476,11 @@ var show = defineCommand8({
|
|
|
405
476
|
run: async ({ args: args2 }) => {
|
|
406
477
|
const client = await connect();
|
|
407
478
|
const playlist2 = await client.playlists.get(Number(args2.id));
|
|
408
|
-
console.log(
|
|
409
|
-
|
|
410
|
-
console.log(`
|
|
479
|
+
console.log(`
|
|
480
|
+
${bold2(`\u{1F4DD} ${playlist2.name}`)}`);
|
|
481
|
+
console.log(` ${dim(`${playlist2.tracksCount ?? 0} tracks`)}`);
|
|
482
|
+
if (playlist2.description) console.log(` ${dim(playlist2.description)}`);
|
|
483
|
+
console.log(` ${link(client.deepLink.playlist(playlist2.id))}`);
|
|
411
484
|
}
|
|
412
485
|
});
|
|
413
486
|
var create = defineCommand8({
|
|
@@ -426,7 +499,7 @@ var create = defineCommand8({
|
|
|
426
499
|
name: args2.name,
|
|
427
500
|
isPublic: args2.public
|
|
428
501
|
});
|
|
429
|
-
|
|
502
|
+
success(`created playlist "${playlist2.name}" [${playlist2.id}]`);
|
|
430
503
|
}
|
|
431
504
|
});
|
|
432
505
|
var add2 = defineCommand8({
|
|
@@ -444,7 +517,7 @@ var add2 = defineCommand8({
|
|
|
444
517
|
await client.playlists.addTracks(Number(args2.playlist), [
|
|
445
518
|
Number(args2.track)
|
|
446
519
|
]);
|
|
447
|
-
|
|
520
|
+
success(`added track ${args2.track} to playlist ${args2.playlist}`);
|
|
448
521
|
}
|
|
449
522
|
});
|
|
450
523
|
var remove2 = defineCommand8({
|
|
@@ -455,7 +528,7 @@ var remove2 = defineCommand8({
|
|
|
455
528
|
run: async ({ args: args2 }) => {
|
|
456
529
|
const client = await connect();
|
|
457
530
|
await client.playlists.remove(Number(args2.id));
|
|
458
|
-
|
|
531
|
+
success(`deleted playlist ${args2.id}`);
|
|
459
532
|
}
|
|
460
533
|
});
|
|
461
534
|
var playlist = defineCommand8({
|
|
@@ -484,25 +557,41 @@ var search = defineCommand9({
|
|
|
484
557
|
limit: Number(args2.limit)
|
|
485
558
|
});
|
|
486
559
|
if (results.albums.length) {
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
560
|
+
heading("\u{1F4BF} Albums");
|
|
561
|
+
console.log(
|
|
562
|
+
columns(
|
|
563
|
+
results.albums.map((album2) => [
|
|
564
|
+
accent(album2.title),
|
|
565
|
+
dim(album2.artist?.name ?? "?"),
|
|
566
|
+
muted(String(album2.id))
|
|
567
|
+
])
|
|
568
|
+
)
|
|
569
|
+
);
|
|
493
570
|
}
|
|
494
571
|
if (results.artists.length) {
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
572
|
+
heading("\u{1F3A4} Artists");
|
|
573
|
+
console.log(
|
|
574
|
+
columns(
|
|
575
|
+
results.artists.map((artist2) => [
|
|
576
|
+
accent(artist2.name),
|
|
577
|
+
muted(String(artist2.id))
|
|
578
|
+
])
|
|
579
|
+
)
|
|
580
|
+
);
|
|
498
581
|
}
|
|
499
582
|
if (results.tracks.length) {
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
583
|
+
heading("\u{1F3B5} Tracks");
|
|
584
|
+
console.log(
|
|
585
|
+
columns(
|
|
586
|
+
results.tracks.map((track2) => [
|
|
587
|
+
accent(track2.title),
|
|
588
|
+
dim(track2.artist?.name ?? "?"),
|
|
589
|
+
dim(formatDuration(track2.duration)),
|
|
590
|
+
muted(String(track2.id))
|
|
591
|
+
]),
|
|
592
|
+
["left", "left", "right", "left"]
|
|
593
|
+
)
|
|
594
|
+
);
|
|
506
595
|
}
|
|
507
596
|
}
|
|
508
597
|
});
|
|
@@ -520,13 +609,89 @@ var similar = defineCommand10({
|
|
|
520
609
|
run: async ({ args: args2 }) => {
|
|
521
610
|
const client = await connect();
|
|
522
611
|
const artists = await client.artists.getSimilar(Number(args2.id));
|
|
523
|
-
|
|
612
|
+
if (!artists.length) return;
|
|
613
|
+
heading("\u{1F3A4} Similar artists");
|
|
614
|
+
console.log(
|
|
615
|
+
columns(
|
|
616
|
+
artists.map((artist2) => [
|
|
617
|
+
accent(artist2.name),
|
|
618
|
+
muted(String(artist2.id))
|
|
619
|
+
])
|
|
620
|
+
)
|
|
621
|
+
);
|
|
524
622
|
}
|
|
525
623
|
});
|
|
526
624
|
|
|
527
|
-
// src/commands/
|
|
625
|
+
// src/commands/stats.ts
|
|
528
626
|
import { defineCommand as defineCommand11 } from "citty";
|
|
529
|
-
|
|
627
|
+
import { readLibraryStats } from "@kud/qobuz";
|
|
628
|
+
var n = (value) => value.toLocaleString("en-US");
|
|
629
|
+
var pct = (count, total) => total ? `${Math.round(1e3 * count / total) / 10}%` : "";
|
|
630
|
+
var chart = (title, rows, scaleMax) => {
|
|
631
|
+
if (!rows.length) return;
|
|
632
|
+
const max = scaleMax ?? Math.max(...rows.map((r) => r.value));
|
|
633
|
+
const labelWidth = Math.max(...rows.map((r) => r.label.length));
|
|
634
|
+
const valueWidth = Math.max(...rows.map((r) => n(r.value).length));
|
|
635
|
+
console.log(`
|
|
636
|
+
${bold2(title)}`);
|
|
637
|
+
for (const { label, value, suffix } of rows) {
|
|
638
|
+
const line = ` ${label.padEnd(labelWidth)} ${accent(bar(value, max))} ${dim(n(value).padStart(valueWidth))}`;
|
|
639
|
+
console.log(suffix ? `${line} ${dim(suffix)}` : line);
|
|
640
|
+
}
|
|
641
|
+
};
|
|
642
|
+
var stats = defineCommand11({
|
|
643
|
+
meta: {
|
|
644
|
+
name: "stats",
|
|
645
|
+
description: "Show collection analytics from your Qobuz desktop library"
|
|
646
|
+
},
|
|
647
|
+
args: {
|
|
648
|
+
limit: { type: "string", description: "Rows per breakdown", default: "10" }
|
|
649
|
+
},
|
|
650
|
+
run: async ({ args: args2 }) => {
|
|
651
|
+
const data = await readLibraryStats({ limit: Number(args2.limit) });
|
|
652
|
+
if (!data) {
|
|
653
|
+
console.error(
|
|
654
|
+
"No Qobuz library found \u2014 is the desktop app installed (macOS)?"
|
|
655
|
+
);
|
|
656
|
+
process.exit(1);
|
|
657
|
+
}
|
|
658
|
+
const { totals, quality, topGenres, topLabels, topArtists, recentlyAdded } = data;
|
|
659
|
+
console.log(
|
|
660
|
+
`${bold2("\u{1F4CA} Collection")} ${dim(
|
|
661
|
+
`${n(totals.offlineAlbums)} albums \xB7 ${n(totals.offlineArtists)} artists \xB7 ${n(totals.offlineTracks)} offline \xB7 ${n(totals.savedTracks)} saved`
|
|
662
|
+
)}`
|
|
663
|
+
);
|
|
664
|
+
chart(
|
|
665
|
+
"\u{1F39A}\uFE0F Quality \xB7 offline tracks",
|
|
666
|
+
quality.map((q) => ({
|
|
667
|
+
label: `${q.bitDepth}-bit`,
|
|
668
|
+
value: q.count,
|
|
669
|
+
suffix: pct(q.count, totals.offlineTracks)
|
|
670
|
+
})),
|
|
671
|
+
totals.offlineTracks
|
|
672
|
+
);
|
|
673
|
+
chart(
|
|
674
|
+
"\u{1F3B8} Top genres",
|
|
675
|
+
topGenres.map((g) => ({ label: g.name, value: g.count }))
|
|
676
|
+
);
|
|
677
|
+
chart(
|
|
678
|
+
"\u{1F3A4} Top artists \xB7 by albums",
|
|
679
|
+
topArtists.map((a) => ({ label: a.name, value: a.count }))
|
|
680
|
+
);
|
|
681
|
+
chart(
|
|
682
|
+
"\u{1F3F7}\uFE0F Top labels",
|
|
683
|
+
topLabels.map((l) => ({ label: l.name, value: l.count }))
|
|
684
|
+
);
|
|
685
|
+
chart(
|
|
686
|
+
"\u{1F4C5} Added recently",
|
|
687
|
+
recentlyAdded.map((m) => ({ label: m.month, value: m.count }))
|
|
688
|
+
);
|
|
689
|
+
}
|
|
690
|
+
});
|
|
691
|
+
|
|
692
|
+
// src/commands/track.ts
|
|
693
|
+
import { defineCommand as defineCommand12 } from "citty";
|
|
694
|
+
var track = defineCommand12({
|
|
530
695
|
meta: { name: "track", description: "Show track details" },
|
|
531
696
|
args: {
|
|
532
697
|
id: { type: "positional", description: "Track ID", required: true }
|
|
@@ -534,19 +699,22 @@ var track = defineCommand11({
|
|
|
534
699
|
run: async ({ args: args2 }) => {
|
|
535
700
|
const client = await connect();
|
|
536
701
|
const track2 = await client.tracks.get(Number(args2.id));
|
|
537
|
-
|
|
702
|
+
const meta = [
|
|
703
|
+
formatDuration(track2.duration),
|
|
704
|
+
track2.hires ? "Hi-Res" : void 0
|
|
705
|
+
].filter(Boolean).join(" \xB7 ");
|
|
706
|
+
console.log(`
|
|
707
|
+
${bold2(`\u{1F3B5} ${track2.title}`)}`);
|
|
538
708
|
console.log(
|
|
539
|
-
`by ${track2.artist?.name ?? "?"}${track2.album ? ` \xB7 ${track2.album.title}` : ""}`
|
|
709
|
+
` ${dim(`by ${track2.artist?.name ?? "?"}${track2.album ? ` \xB7 ${track2.album.title}` : ""}`)}`
|
|
540
710
|
);
|
|
541
|
-
console.log(
|
|
542
|
-
|
|
543
|
-
);
|
|
544
|
-
console.log(`open: ${client.deepLink.track(track2.id)}`);
|
|
711
|
+
if (meta) console.log(` ${dim(meta)}`);
|
|
712
|
+
console.log(` ${link(client.deepLink.track(track2.id))}`);
|
|
545
713
|
}
|
|
546
714
|
});
|
|
547
715
|
|
|
548
716
|
// src/commands/url.ts
|
|
549
|
-
import { defineCommand as
|
|
717
|
+
import { defineCommand as defineCommand13 } from "citty";
|
|
550
718
|
import { readNowPlayingTrackId } from "@kud/qobuz";
|
|
551
719
|
var currentTrackLink = async (client) => {
|
|
552
720
|
const trackId = await readNowPlayingTrackId();
|
|
@@ -563,14 +731,14 @@ var specificLink = (client, type, id) => {
|
|
|
563
731
|
console.error("usage: qobuz url <album|track|playlist|artist> <id>");
|
|
564
732
|
process.exit(1);
|
|
565
733
|
}
|
|
566
|
-
const
|
|
567
|
-
if (!
|
|
734
|
+
const link2 = deepLinkFor(client, type, id);
|
|
735
|
+
if (!link2) {
|
|
568
736
|
console.error("type must be one of: album, track, playlist, artist");
|
|
569
737
|
process.exit(1);
|
|
570
738
|
}
|
|
571
|
-
return
|
|
739
|
+
return link2;
|
|
572
740
|
};
|
|
573
|
-
var url =
|
|
741
|
+
var url = defineCommand13({
|
|
574
742
|
meta: {
|
|
575
743
|
name: "url",
|
|
576
744
|
description: "Copy a deep-link to the clipboard \u2014 the playing track, or a given item"
|
|
@@ -594,18 +762,18 @@ var url = defineCommand12({
|
|
|
594
762
|
},
|
|
595
763
|
run: async ({ args: args2 }) => {
|
|
596
764
|
const client = await connect();
|
|
597
|
-
const
|
|
765
|
+
const link2 = args2.type ? specificLink(client, args2.type, args2.id) : await currentTrackLink(client);
|
|
598
766
|
if (args2.plain) {
|
|
599
|
-
console.log(
|
|
767
|
+
console.log(link2);
|
|
600
768
|
return;
|
|
601
769
|
}
|
|
602
|
-
const copied = await copyToClipboard(
|
|
603
|
-
console.log(copied ? `\u2713 copied ${
|
|
770
|
+
const copied = await copyToClipboard(link2);
|
|
771
|
+
console.log(copied ? `\u2713 copied ${link2}` : link2);
|
|
604
772
|
}
|
|
605
773
|
});
|
|
606
774
|
|
|
607
775
|
// src/index.ts
|
|
608
|
-
var main =
|
|
776
|
+
var main = defineCommand14({
|
|
609
777
|
meta: {
|
|
610
778
|
name: "qobuz",
|
|
611
779
|
description: "Qobuz from the command line \u2014 search, library, and quick-open in the app"
|
|
@@ -620,6 +788,7 @@ var main = defineCommand13({
|
|
|
620
788
|
similar,
|
|
621
789
|
fav,
|
|
622
790
|
playlist,
|
|
791
|
+
stats,
|
|
623
792
|
url,
|
|
624
793
|
open,
|
|
625
794
|
play,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kud/qobuz-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Command-line interface for Qobuz — search, library, and quick-open in the app",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"node": ">=20"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@kud/qobuz": "0.
|
|
28
|
+
"@kud/qobuz": "0.4.0",
|
|
29
29
|
"citty": "0.2.2"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|