@kud/qobuz-cli 0.1.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 ADDED
@@ -0,0 +1,55 @@
1
+ <div align="center">
2
+
3
+ ![npm](https://img.shields.io/npm/v/%40kud%2Fqobuz-cli?style=flat-square&color=CB3837)
4
+ ![Node.js](https://img.shields.io/badge/Node.js-%3E%3D20-339933?style=flat-square&logo=node.js&logoColor=white)
5
+ ![MIT](https://img.shields.io/badge/licence-MIT-22C55E?style=flat-square)
6
+
7
+ **Command-line interface for Qobuz — search, library, and quick-open in the app**
8
+
9
+ <a href="https://kud.io/projects/qobuz-cli">Website</a> · <a href="https://kud.io/projects/qobuz-cli/docs">Documentation</a>
10
+
11
+ </div>
12
+
13
+ ## Features
14
+
15
+ - **Fast search & metadata** — search albums, tracks, and artists; inspect album, artist, and track details.
16
+ - **Library & playlists** — list, add, and remove favourites; list, show, create, and edit playlists.
17
+ - **Media-key playback control** — `play`, `next`, and `previous` drive the Qobuz desktop app via real media keys (macOS, requires Accessibility permission).
18
+ - **Quick open** — `open` and `url` deep-link straight into the Qobuz app.
19
+ - **Secure login** — stores a browser-borrowed token in the macOS Keychain; no password handling.
20
+
21
+ ## Install
22
+
23
+ ```sh
24
+ npm install -g @kud/qobuz-cli
25
+ ```
26
+
27
+ ## Usage
28
+
29
+ ```console
30
+ $ qobuz login # connect (opens browser, paste app_id + token)
31
+ $ qobuz search "radiohead"
32
+ $ qobuz album 0634904032432
33
+ $ qobuz fav list
34
+ $ qobuz playlist create "Focus"
35
+ $ qobuz play # toggle play/pause in Qobuz
36
+ $ qobuz next # skip track
37
+ $ qobuz open album 0634904032432 # open in the Qobuz app
38
+ ```
39
+
40
+ Full command set: `login`, `logout`, `search`, `album`, `artist`, `track`, `similar`, `fav` (list/add/remove), `playlist` (list/show/create/add/remove), `url`, `open`, `play`, `next`, `previous` / `prev`.
41
+
42
+ > **macOS note** — playback commands (`play`, `next`, `previous`) use real media keys and require Accessibility permission granted to your terminal. The first playback command compiles a small Swift helper via `swiftc`.
43
+
44
+ ## Development
45
+
46
+ ```sh
47
+ git clone https://github.com/kud/qobuz-cli.git
48
+ cd qobuz-cli
49
+ npm install
50
+ npm run dev -- search "radiohead" # run from source via tsx
51
+ npm run build
52
+ npm run typecheck
53
+ ```
54
+
55
+ 📚 **Full documentation → [qobuz-cli/docs](https://kud.io/projects/qobuz-cli/docs)**
package/dist/index.js ADDED
@@ -0,0 +1,561 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/index.ts
4
+ import { defineCommand as defineCommand13, runMain } from "citty";
5
+
6
+ // src/commands/album.ts
7
+ import { defineCommand } from "citty";
8
+
9
+ // src/lib.ts
10
+ import {
11
+ createKeychainStore,
12
+ createQobuzClient
13
+ } from "@kud/qobuz";
14
+ var store = createKeychainStore();
15
+ var connect = async () => {
16
+ try {
17
+ return await createQobuzClient({ store });
18
+ } catch (error) {
19
+ const qobuzError = error;
20
+ if (qobuzError.kind === "auth") {
21
+ console.error("Not connected \u2014 run `qobuz login` first.");
22
+ } else {
23
+ console.error(`Error: ${qobuzError.message ?? error}`);
24
+ }
25
+ process.exit(1);
26
+ }
27
+ };
28
+ var formatDuration = (seconds) => {
29
+ if (!seconds) return "";
30
+ const minutes = Math.floor(seconds / 60);
31
+ const remainder = String(seconds % 60).padStart(2, "0");
32
+ return `${minutes}:${remainder}`;
33
+ };
34
+ var deepLinkFor = (client, type, id) => {
35
+ const builders = {
36
+ album: (value) => client.deepLink.album(value),
37
+ track: (value) => client.deepLink.track(Number(value)),
38
+ playlist: (value) => client.deepLink.playlist(Number(value)),
39
+ artist: (value) => client.deepLink.artist(Number(value))
40
+ };
41
+ return builders[type]?.(id);
42
+ };
43
+
44
+ // src/commands/album.ts
45
+ var album = defineCommand({
46
+ meta: { name: "album", description: "Show album details" },
47
+ args: {
48
+ id: { type: "positional", description: "Album ID", required: true }
49
+ },
50
+ run: async ({ args }) => {
51
+ const client = await connect();
52
+ const album2 = await client.albums.get(args.id);
53
+ console.log(`${album2.title}`);
54
+ console.log(`by ${album2.artist?.name ?? "?"}`);
55
+ console.log(
56
+ `${album2.tracksCount ?? "?"} tracks \xB7 released ${album2.releaseDate ?? "?"}${album2.hires ? " \xB7 Hi-Res" : ""}`
57
+ );
58
+ console.log(`open: ${client.deepLink.album(album2.id)}`);
59
+ }
60
+ });
61
+
62
+ // src/commands/artist.ts
63
+ import { defineCommand as defineCommand2 } from "citty";
64
+ var artist = defineCommand2({
65
+ meta: { name: "artist", description: "Show artist details" },
66
+ args: {
67
+ id: { type: "positional", description: "Artist ID", required: true }
68
+ },
69
+ run: async ({ args }) => {
70
+ const client = await connect();
71
+ const artist2 = await client.artists.get(Number(args.id));
72
+ console.log(artist2.name);
73
+ if (artist2.albumsCount !== void 0)
74
+ console.log(`${artist2.albumsCount} albums`);
75
+ console.log(`open: ${client.deepLink.artist(artist2.id)}`);
76
+ }
77
+ });
78
+
79
+ // src/commands/fav.ts
80
+ import { defineCommand as defineCommand3 } from "citty";
81
+ var list = defineCommand3({
82
+ meta: { name: "list", description: "List favourites" },
83
+ args: {
84
+ type: {
85
+ type: "string",
86
+ description: "albums | artists | tracks",
87
+ default: "albums"
88
+ }
89
+ },
90
+ run: async ({ args }) => {
91
+ const client = await connect();
92
+ const favourites = await client.favourites.list(args.type);
93
+ for (const album2 of favourites.albums)
94
+ console.log(
95
+ ` ${album2.id} ${album2.artist?.name ?? "?"} \u2014 ${album2.title}`
96
+ );
97
+ for (const artist2 of favourites.artists)
98
+ console.log(` ${artist2.id} ${artist2.name}`);
99
+ for (const track2 of favourites.tracks)
100
+ console.log(
101
+ ` ${track2.id} ${track2.artist?.name ?? "?"} \u2014 ${track2.title}`
102
+ );
103
+ }
104
+ });
105
+ var add = defineCommand3({
106
+ meta: { name: "add", description: "Add a favourite" },
107
+ args: {
108
+ type: {
109
+ type: "positional",
110
+ description: "albums | artists | tracks",
111
+ required: true
112
+ },
113
+ id: {
114
+ type: "positional",
115
+ description: "Album/artist/track ID",
116
+ required: true
117
+ }
118
+ },
119
+ run: async ({ args }) => {
120
+ const client = await connect();
121
+ await client.favourites.add(args.type, args.id);
122
+ console.log(`\u2713 added ${args.type} ${args.id} to favourites`);
123
+ }
124
+ });
125
+ var remove = defineCommand3({
126
+ meta: { name: "remove", description: "Remove a favourite" },
127
+ args: {
128
+ type: {
129
+ type: "positional",
130
+ description: "albums | artists | tracks",
131
+ required: true
132
+ },
133
+ id: {
134
+ type: "positional",
135
+ description: "Album/artist/track ID",
136
+ required: true
137
+ }
138
+ },
139
+ run: async ({ args }) => {
140
+ const client = await connect();
141
+ await client.favourites.remove(args.type, args.id);
142
+ console.log(`\u2713 removed ${args.type} ${args.id} from favourites`);
143
+ }
144
+ });
145
+ var fav = defineCommand3({
146
+ meta: { name: "fav", description: "Manage favourites" },
147
+ subCommands: { list, add, remove }
148
+ });
149
+
150
+ // src/commands/login.ts
151
+ import { defineCommand as defineCommand4 } from "citty";
152
+
153
+ // src/connect.ts
154
+ import { fetchAppId, validateCredentials } from "@kud/qobuz";
155
+
156
+ // src/prompts.ts
157
+ import readline from "readline";
158
+ import { execFile } from "child_process";
159
+ import { promisify } from "util";
160
+ var exec = promisify(execFile);
161
+ var createPrompts = () => {
162
+ const rl = readline.createInterface({
163
+ input: process.stdin,
164
+ output: process.stdout
165
+ });
166
+ const ask = (question) => new Promise(
167
+ (resolve) => rl.question(question, (answer) => resolve(answer.trim()))
168
+ );
169
+ const askHidden = (question) => new Promise((resolve) => {
170
+ let muted = false;
171
+ rl._writeToOutput = (chunk) => {
172
+ if (!muted) process.stdout.write(chunk);
173
+ };
174
+ rl.question(question, (answer) => {
175
+ rl._writeToOutput = (chunk) => process.stdout.write(chunk);
176
+ process.stdout.write("\n");
177
+ resolve(answer);
178
+ });
179
+ muted = true;
180
+ });
181
+ return { ask, askHidden, close: () => rl.close() };
182
+ };
183
+ var openUrl = async (url2) => {
184
+ try {
185
+ await exec("open", [url2]);
186
+ return true;
187
+ } catch {
188
+ return false;
189
+ }
190
+ };
191
+ var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
192
+ var countdownAndOpen = async (url2, seconds = 3) => {
193
+ for (const n of Array.from({ length: seconds }, (_, i) => seconds - i)) {
194
+ process.stdout.write(`\r Opening ${url2} in ${n}\u2026 `);
195
+ await sleep(1e3);
196
+ }
197
+ process.stdout.write(`\r Opening ${url2} now.${" ".repeat(20)}
198
+
199
+ `);
200
+ if (!await openUrl(url2))
201
+ console.log(` (couldn't open a browser \u2014 visit ${url2} manually)`);
202
+ };
203
+
204
+ // src/connect.ts
205
+ var runConnect = async () => {
206
+ console.log("Connect your Qobuz account.");
207
+ console.log(
208
+ "In the page that opens: log in, then DevTools \u2192 Network, click any"
209
+ );
210
+ console.log(
211
+ "request to www.qobuz.com/api.json and copy these from its headers:\n"
212
+ );
213
+ const scraped = await fetchAppId().then((result) => result.appId).catch(() => "");
214
+ await countdownAndOpen("https://play.qobuz.com/login");
215
+ const prompts = createPrompts();
216
+ const appIdInput = await prompts.ask(
217
+ ` X-App-Id${scraped ? ` [${scraped}]` : ""}: `
218
+ );
219
+ const token = await prompts.askHidden(" X-User-Auth-Token: ");
220
+ prompts.close();
221
+ const appId = appIdInput || scraped;
222
+ if (!appId || !token) {
223
+ console.error("\nBoth X-App-Id and X-User-Auth-Token are required.");
224
+ process.exit(1);
225
+ }
226
+ process.stdout.write("\n Validating\u2026 ");
227
+ try {
228
+ await validateCredentials({ appId, token });
229
+ } catch (error) {
230
+ console.error(`
231
+ \u2717 ${error.message}`);
232
+ process.exit(1);
233
+ }
234
+ await store.save({ appId, token });
235
+ console.log('\u2713 connected. Session saved to the Keychain (service "qobuz").');
236
+ };
237
+
238
+ // src/commands/login.ts
239
+ var login = defineCommand4({
240
+ meta: {
241
+ name: "login",
242
+ description: "Connect your Qobuz account (stores a token in the Keychain)"
243
+ },
244
+ run: () => runConnect()
245
+ });
246
+
247
+ // src/commands/logout.ts
248
+ import { defineCommand as defineCommand5 } from "citty";
249
+ var logout = defineCommand5({
250
+ meta: {
251
+ name: "logout",
252
+ description: "Remove the stored Qobuz session from the Keychain"
253
+ },
254
+ run: async () => {
255
+ await store.clear();
256
+ console.log("\u2713 logged out. Keychain session cleared.");
257
+ }
258
+ });
259
+
260
+ // src/commands/open.ts
261
+ import { defineCommand as defineCommand6 } from "citty";
262
+ var open = defineCommand6({
263
+ meta: {
264
+ name: "open",
265
+ description: "Open an album/track/playlist/artist in the Qobuz app"
266
+ },
267
+ args: {
268
+ type: {
269
+ type: "positional",
270
+ description: "album | track | playlist | artist",
271
+ required: true
272
+ },
273
+ id: { type: "positional", description: "ID", required: true }
274
+ },
275
+ run: async ({ args }) => {
276
+ const client = await connect();
277
+ const link = deepLinkFor(client, args.type, args.id);
278
+ if (!link) {
279
+ console.error("type must be one of: album, track, playlist, artist");
280
+ process.exit(1);
281
+ }
282
+ console.log(`opening ${link}`);
283
+ await openUrl(link);
284
+ }
285
+ });
286
+
287
+ // src/commands/playback.ts
288
+ import { defineCommand as defineCommand7 } from "citty";
289
+
290
+ // src/media-key.ts
291
+ import { execFile as execFile2 } from "child_process";
292
+ import { existsSync } from "fs";
293
+ import { dirname, join } from "path";
294
+ import { fileURLToPath } from "url";
295
+ import { promisify as promisify2 } from "util";
296
+ var exec2 = promisify2(execFile2);
297
+ var findPackageRoot = () => {
298
+ let dir = dirname(fileURLToPath(import.meta.url));
299
+ while (!existsSync(join(dir, "package.json"))) {
300
+ const parent = dirname(dir);
301
+ if (parent === dir)
302
+ throw new Error("could not locate the qobuz-cli package root");
303
+ dir = parent;
304
+ }
305
+ return dir;
306
+ };
307
+ var root = findPackageRoot();
308
+ var source = join(root, "native", "media-key.swift");
309
+ var binary = join(root, "native", "media-key");
310
+ var ensureBinary = async () => {
311
+ if (!existsSync(binary)) await exec2("swiftc", ["-O", source, "-o", binary]);
312
+ return binary;
313
+ };
314
+ var sendMediaKey = async (key) => {
315
+ const bin = await ensureBinary();
316
+ try {
317
+ await exec2(bin, [key]);
318
+ } catch (error) {
319
+ throw new Error(
320
+ (error.stderr ?? String(error)).trim()
321
+ );
322
+ }
323
+ };
324
+
325
+ // src/commands/playback.ts
326
+ var playbackCommand = (name, description, key) => defineCommand7({
327
+ meta: { name, description },
328
+ run: async () => {
329
+ try {
330
+ await sendMediaKey(key);
331
+ } catch (error) {
332
+ console.error(error.message);
333
+ process.exit(1);
334
+ }
335
+ }
336
+ });
337
+ var play = playbackCommand(
338
+ "play",
339
+ "Toggle play/pause in the active player (Qobuz)",
340
+ "play"
341
+ );
342
+ var next = playbackCommand("next", "Skip to the next track", "next");
343
+ var previous = playbackCommand(
344
+ "previous",
345
+ "Go to the previous track",
346
+ "previous"
347
+ );
348
+
349
+ // src/commands/playlist.ts
350
+ import { defineCommand as defineCommand8 } from "citty";
351
+ var list2 = defineCommand8({
352
+ meta: { name: "list", description: "List your playlists" },
353
+ run: async () => {
354
+ const client = await connect();
355
+ const playlists = await client.playlists.listForUser();
356
+ for (const playlist2 of playlists) {
357
+ console.log(
358
+ ` ${playlist2.id} ${playlist2.name} (${playlist2.tracksCount ?? 0} tracks)`
359
+ );
360
+ }
361
+ }
362
+ });
363
+ var show = defineCommand8({
364
+ meta: { name: "show", description: "Show a playlist" },
365
+ args: {
366
+ id: { type: "positional", description: "Playlist ID", required: true }
367
+ },
368
+ run: async ({ args }) => {
369
+ const client = await connect();
370
+ const playlist2 = await client.playlists.get(Number(args.id));
371
+ console.log(`${playlist2.name} (${playlist2.tracksCount ?? 0} tracks)`);
372
+ if (playlist2.description) console.log(playlist2.description);
373
+ console.log(`open: ${client.deepLink.playlist(playlist2.id)}`);
374
+ }
375
+ });
376
+ var create = defineCommand8({
377
+ meta: { name: "create", description: "Create a playlist" },
378
+ args: {
379
+ name: { type: "positional", description: "Playlist name", required: true },
380
+ public: {
381
+ type: "boolean",
382
+ description: "Make the playlist public",
383
+ default: false
384
+ }
385
+ },
386
+ run: async ({ args }) => {
387
+ const client = await connect();
388
+ const playlist2 = await client.playlists.create({
389
+ name: args.name,
390
+ isPublic: args.public
391
+ });
392
+ console.log(`\u2713 created playlist "${playlist2.name}" [${playlist2.id}]`);
393
+ }
394
+ });
395
+ var add2 = defineCommand8({
396
+ meta: { name: "add", description: "Add a track to a playlist" },
397
+ args: {
398
+ playlist: {
399
+ type: "positional",
400
+ description: "Playlist ID",
401
+ required: true
402
+ },
403
+ track: { type: "positional", description: "Track ID", required: true }
404
+ },
405
+ run: async ({ args }) => {
406
+ const client = await connect();
407
+ await client.playlists.addTracks(Number(args.playlist), [
408
+ Number(args.track)
409
+ ]);
410
+ console.log(`\u2713 added track ${args.track} to playlist ${args.playlist}`);
411
+ }
412
+ });
413
+ var remove2 = defineCommand8({
414
+ meta: { name: "remove", description: "Delete a playlist" },
415
+ args: {
416
+ id: { type: "positional", description: "Playlist ID", required: true }
417
+ },
418
+ run: async ({ args }) => {
419
+ const client = await connect();
420
+ await client.playlists.remove(Number(args.id));
421
+ console.log(`\u2713 deleted playlist ${args.id}`);
422
+ }
423
+ });
424
+ var playlist = defineCommand8({
425
+ meta: { name: "playlist", description: "Manage playlists" },
426
+ subCommands: { list: list2, show, create, add: add2, remove: remove2 }
427
+ });
428
+
429
+ // src/commands/search.ts
430
+ import { defineCommand as defineCommand9 } from "citty";
431
+ var search = defineCommand9({
432
+ meta: {
433
+ name: "search",
434
+ description: "Search Qobuz for albums, tracks, and artists"
435
+ },
436
+ args: {
437
+ query: { type: "positional", description: "Search query", required: true },
438
+ limit: {
439
+ type: "string",
440
+ description: "Max results per category",
441
+ default: "10"
442
+ }
443
+ },
444
+ run: async ({ args }) => {
445
+ const client = await connect();
446
+ const results = await client.search.search(args.query, {
447
+ limit: Number(args.limit)
448
+ });
449
+ if (results.albums.length) {
450
+ console.log("\nAlbums");
451
+ for (const album2 of results.albums) {
452
+ console.log(
453
+ ` ${album2.id} ${album2.artist?.name ?? "?"} \u2014 ${album2.title}`
454
+ );
455
+ }
456
+ }
457
+ if (results.artists.length) {
458
+ console.log("\nArtists");
459
+ for (const artist2 of results.artists)
460
+ console.log(` ${artist2.id} ${artist2.name}`);
461
+ }
462
+ if (results.tracks.length) {
463
+ console.log("\nTracks");
464
+ for (const track2 of results.tracks) {
465
+ console.log(
466
+ ` ${track2.id} ${track2.artist?.name ?? "?"} \u2014 ${track2.title} ${formatDuration(track2.duration)}`
467
+ );
468
+ }
469
+ }
470
+ }
471
+ });
472
+
473
+ // src/commands/similar.ts
474
+ import { defineCommand as defineCommand10 } from "citty";
475
+ var similar = defineCommand10({
476
+ meta: {
477
+ name: "similar",
478
+ description: "List artists similar to the given artist"
479
+ },
480
+ args: {
481
+ id: { type: "positional", description: "Artist ID", required: true }
482
+ },
483
+ run: async ({ args }) => {
484
+ const client = await connect();
485
+ const artists = await client.artists.getSimilar(Number(args.id));
486
+ for (const artist2 of artists) console.log(` ${artist2.id} ${artist2.name}`);
487
+ }
488
+ });
489
+
490
+ // src/commands/track.ts
491
+ import { defineCommand as defineCommand11 } from "citty";
492
+ var track = defineCommand11({
493
+ meta: { name: "track", description: "Show track details" },
494
+ args: {
495
+ id: { type: "positional", description: "Track ID", required: true }
496
+ },
497
+ run: async ({ args }) => {
498
+ const client = await connect();
499
+ const track2 = await client.tracks.get(Number(args.id));
500
+ console.log(track2.title);
501
+ console.log(
502
+ `by ${track2.artist?.name ?? "?"}${track2.album ? ` \xB7 ${track2.album.title}` : ""}`
503
+ );
504
+ console.log(
505
+ `${formatDuration(track2.duration)}${track2.hires ? " \xB7 Hi-Res" : ""}`
506
+ );
507
+ console.log(`open: ${client.deepLink.track(track2.id)}`);
508
+ }
509
+ });
510
+
511
+ // src/commands/url.ts
512
+ import { defineCommand as defineCommand12 } from "citty";
513
+ var url = defineCommand12({
514
+ meta: {
515
+ name: "url",
516
+ description: "Print the open.qobuz.com deep-link for an item (without opening it)"
517
+ },
518
+ args: {
519
+ type: {
520
+ type: "positional",
521
+ description: "album | track | playlist | artist",
522
+ required: true
523
+ },
524
+ id: { type: "positional", description: "ID", required: true }
525
+ },
526
+ run: async ({ args }) => {
527
+ const client = await connect();
528
+ const link = deepLinkFor(client, args.type, args.id);
529
+ if (!link) {
530
+ console.error("type must be one of: album, track, playlist, artist");
531
+ process.exit(1);
532
+ }
533
+ console.log(link);
534
+ }
535
+ });
536
+
537
+ // src/index.ts
538
+ var main = defineCommand13({
539
+ meta: {
540
+ name: "qobuz",
541
+ description: "Qobuz from the command line \u2014 search, library, and quick-open in the app"
542
+ },
543
+ subCommands: {
544
+ login,
545
+ logout,
546
+ search,
547
+ album,
548
+ artist,
549
+ track,
550
+ similar,
551
+ fav,
552
+ playlist,
553
+ url,
554
+ open,
555
+ play,
556
+ next,
557
+ previous,
558
+ prev: previous
559
+ }
560
+ });
561
+ runMain(main);
@@ -0,0 +1,51 @@
1
+ import ApplicationServices
2
+ import Cocoa
3
+
4
+ // IOKit ev_keymap.h media key codes.
5
+ let keyCodes: [String: Int32] = [
6
+ "play": 16, // NX_KEYTYPE_PLAY — play/pause toggle
7
+ "next": 17, // NX_KEYTYPE_NEXT
8
+ "previous": 18, // NX_KEYTYPE_PREVIOUS
9
+ ]
10
+
11
+ func postMediaKey(_ key: Int32) {
12
+ func send(down: Bool) {
13
+ let flags = NSEvent.ModifierFlags(rawValue: down ? 0xA00 : 0xB00)
14
+ let data1 = Int((key << 16) | (down ? 0xA00 : 0xB00))
15
+ let event = NSEvent.otherEvent(
16
+ with: .systemDefined,
17
+ location: .zero,
18
+ modifierFlags: flags,
19
+ timestamp: 0,
20
+ windowNumber: 0,
21
+ context: nil,
22
+ subtype: 8,
23
+ data1: data1,
24
+ data2: -1
25
+ )
26
+ event?.cgEvent?.post(tap: .cghidEventTap)
27
+ }
28
+ send(down: true)
29
+ usleep(1000)
30
+ send(down: false)
31
+ }
32
+
33
+ let fail = { (message: String, code: Int32) in
34
+ FileHandle.standardError.write(Data("\(message)\n".utf8))
35
+ exit(code)
36
+ }
37
+
38
+ guard let name = CommandLine.arguments.dropFirst().first, let key = keyCodes[name] else {
39
+ fail("usage: media-key <play|next|previous>", 64)
40
+ exit(64)
41
+ }
42
+
43
+ guard AXIsProcessTrusted() else {
44
+ fail(
45
+ "not authorized — grant your terminal Accessibility access in System Settings → Privacy & Security → Accessibility",
46
+ 77
47
+ )
48
+ exit(77)
49
+ }
50
+
51
+ postMediaKey(key)
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "@kud/qobuz-cli",
3
+ "version": "0.1.0",
4
+ "description": "Command-line interface for Qobuz — search, library, and quick-open in the app",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "bin": {
8
+ "qobuz": "./dist/index.js"
9
+ },
10
+ "files": [
11
+ "dist",
12
+ "native/media-key.swift"
13
+ ],
14
+ "scripts": {
15
+ "build": "npm run build:native && tsup",
16
+ "build:native": "swiftc -O native/media-key.swift -o native/media-key",
17
+ "dev": "tsx src/index.ts",
18
+ "typecheck": "tsc --noEmit"
19
+ },
20
+ "engines": {
21
+ "node": ">=20"
22
+ },
23
+ "dependencies": {
24
+ "@kud/qobuz": "0.1.0",
25
+ "citty": "0.2.2"
26
+ },
27
+ "devDependencies": {
28
+ "@types/node": "26.0.0",
29
+ "tsup": "8.5.1",
30
+ "tsx": "4.22.4",
31
+ "typescript": "6.0.3"
32
+ }
33
+ }