@audd/sdk 1.5.11 → 1.5.13
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 +9 -8
- package/dist/index.cjs +203 -156
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +36 -27
- package/dist/index.d.ts +36 -27
- package/dist/index.js +203 -156
- package/dist/index.js.map +1 -1
- package/dist/longpoll.cjs +71 -25
- package/dist/longpoll.cjs.map +1 -1
- package/dist/longpoll.d.cts +2 -2
- package/dist/longpoll.d.ts +2 -2
- package/dist/longpoll.js +71 -25
- package/dist/longpoll.js.map +1 -1
- package/dist/{longpollCore-ZtFOyojP.d.cts → longpollCore-BXx8PRmC.d.cts} +1 -1
- package/dist/{longpollCore-ZtFOyojP.d.ts → longpollCore-BXx8PRmC.d.ts} +1 -1
- package/package.json +19 -10
package/README.md
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# audd-node
|
|
2
2
|
|
|
3
|
+
[](https://audd.io)
|
|
3
4
|
[](https://github.com/AudDMusic/audd-node/actions/workflows/ci.yml)
|
|
4
5
|
[](https://github.com/AudDMusic/audd-node/actions/workflows/contract.yml)
|
|
5
6
|
[](https://www.npmjs.com/package/@audd/sdk)
|
|
@@ -52,7 +53,7 @@ found no match — distinct from an error, which throws.
|
|
|
52
53
|
Pass the token literally:
|
|
53
54
|
|
|
54
55
|
```ts
|
|
55
|
-
const audd = new AudD("
|
|
56
|
+
const audd = new AudD("your-api-token");
|
|
56
57
|
```
|
|
57
58
|
|
|
58
59
|
Or set `AUDD_API_TOKEN` in the environment and construct without
|
|
@@ -273,7 +274,7 @@ app.use(express.json());
|
|
|
273
274
|
app.post("/audd-callback", async (req, res) => {
|
|
274
275
|
const { match, notification } = await handleCallback(req);
|
|
275
276
|
if (match) {
|
|
276
|
-
console.log(`${match.song
|
|
277
|
+
console.log(`${match.song?.artist ?? "?"} - ${match.song?.title ?? "?"} score=${match.song?.score ?? "?"}`);
|
|
277
278
|
for (const alt of match.alternatives) {
|
|
278
279
|
// alternatives are variant catalog releases — different artist/title is possible
|
|
279
280
|
console.log(` alt: ${alt.artist} - ${alt.title}`);
|
|
@@ -303,7 +304,7 @@ import { handleCallback } from "@audd/sdk";
|
|
|
303
304
|
const app = Fastify();
|
|
304
305
|
app.post("/audd-callback", async (req, reply) => {
|
|
305
306
|
const { match } = await handleCallback(req);
|
|
306
|
-
if (match) console.log(`${match.song
|
|
307
|
+
if (match) console.log(`${match.song?.artist ?? "?"} — ${match.song?.title ?? "?"}`);
|
|
307
308
|
return { ok: true };
|
|
308
309
|
});
|
|
309
310
|
```
|
|
@@ -322,7 +323,7 @@ const router = new Router();
|
|
|
322
323
|
app.use(bodyParser());
|
|
323
324
|
router.post("/audd-callback", async (ctx) => {
|
|
324
325
|
const { match } = await handleCallback(ctx.request);
|
|
325
|
-
if (match) console.log(`${match.song
|
|
326
|
+
if (match) console.log(`${match.song?.artist ?? "?"} — ${match.song?.title ?? "?"}`);
|
|
326
327
|
ctx.body = { ok: true };
|
|
327
328
|
});
|
|
328
329
|
app.use(router.routes());
|
|
@@ -336,7 +337,7 @@ import { handleCallback } from "@audd/sdk";
|
|
|
336
337
|
|
|
337
338
|
export async function POST(req: NextRequest) {
|
|
338
339
|
const { match } = await handleCallback(req);
|
|
339
|
-
if (match) console.log(`${match.song
|
|
340
|
+
if (match) console.log(`${match.song?.artist ?? "?"} — ${match.song?.title ?? "?"}`);
|
|
340
341
|
return NextResponse.json({ ok: true });
|
|
341
342
|
}
|
|
342
343
|
```
|
|
@@ -358,7 +359,7 @@ const radioId = 1; // any integer you choose — your handle for this stream
|
|
|
358
359
|
|
|
359
360
|
const poll = await audd.streams.longpoll({ radioId, timeout: 30 });
|
|
360
361
|
for await (const m of poll.matches) {
|
|
361
|
-
console.log(m.song
|
|
362
|
+
console.log(m.song?.artist ?? "?", m.song?.title ?? "?");
|
|
362
363
|
}
|
|
363
364
|
```
|
|
364
365
|
|
|
@@ -368,7 +369,7 @@ Consume matches and notifications concurrently:
|
|
|
368
369
|
await Promise.all([
|
|
369
370
|
(async () => {
|
|
370
371
|
for await (const m of poll.matches) {
|
|
371
|
-
console.log("match:", m.song
|
|
372
|
+
console.log("match:", m.song?.artist ?? "?", m.song?.title ?? "?");
|
|
372
373
|
}
|
|
373
374
|
})(),
|
|
374
375
|
(async () => {
|
|
@@ -401,7 +402,7 @@ import { LongpollConsumer } from "@audd/sdk/longpoll";
|
|
|
401
402
|
const consumer = new LongpollConsumer("abc123def");
|
|
402
403
|
const poll = consumer.iterate({ timeout: 30 });
|
|
403
404
|
for await (const m of poll.matches) {
|
|
404
|
-
console.log(m.song
|
|
405
|
+
console.log(m.song?.artist ?? "?", m.song?.title ?? "?");
|
|
405
406
|
}
|
|
406
407
|
```
|
|
407
408
|
|