@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 CHANGED
@@ -1,5 +1,6 @@
1
1
  # audd-node
2
2
 
3
+ [![Powered by AudD](https://img.shields.io/badge/Music_Recognition-AudD_API-2a4eef)](https://audd.io)
3
4
  [![CI](https://github.com/AudDMusic/audd-node/actions/workflows/ci.yml/badge.svg)](https://github.com/AudDMusic/audd-node/actions/workflows/ci.yml)
4
5
  [![Contract](https://github.com/AudDMusic/audd-node/actions/workflows/contract.yml/badge.svg)](https://github.com/AudDMusic/audd-node/actions/workflows/contract.yml)
5
6
  [![npm](https://img.shields.io/npm/v/@audd/sdk.svg)](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("d29ebb...");
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.artist} - ${match.song.title} score=${match.song.score}`);
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.artist} — ${match.song.title}`);
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.artist} — ${match.song.title}`);
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.artist} — ${match.song.title}`);
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.artist, m.song.title);
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.artist, m.song.title);
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.artist, m.song.title);
405
+ console.log(m.song?.artist ?? "?", m.song?.title ?? "?");
405
406
  }
406
407
  ```
407
408