@audd/sdk 1.5.10 → 1.5.12
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 +18 -12
- package/dist/index.cjs +196 -147
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +37 -27
- package/dist/index.d.ts +37 -27
- package/dist/index.js +196 -147
- package/dist/index.js.map +1 -1
- package/dist/longpoll.cjs +39 -18
- 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 +39 -18
- package/dist/longpoll.js.map +1 -1
- package/dist/{longpollCore-BRyps2P4.d.cts → longpollCore-BXx8PRmC.d.cts} +8 -5
- package/dist/{longpollCore-BRyps2P4.d.ts → longpollCore-BXx8PRmC.d.ts} +8 -5
- 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
|
|
@@ -145,10 +146,15 @@ for (const m of matches) {
|
|
|
145
146
|
}
|
|
146
147
|
```
|
|
147
148
|
|
|
148
|
-
`EnterpriseMatch` carries the same core tags plus `score`, `
|
|
149
|
-
`
|
|
150
|
-
|
|
151
|
-
|
|
149
|
+
`EnterpriseMatch` carries the same core tags plus `score`, `startSeconds`,
|
|
150
|
+
`endSeconds`, `startOffset`, `endOffset`, `isrc`, `upc`. `startSeconds` and
|
|
151
|
+
`endSeconds` are where this song plays in your file, in seconds (e.g. 64.2 to
|
|
152
|
+
71.8) — feed straight to a player or ffmpeg; computed while parsing the chunked
|
|
153
|
+
response, and `recognizeEnterprise` requests accurate offsets by default so
|
|
154
|
+
they're precise. `startOffset`/`endOffset` are the raw millisecond positions
|
|
155
|
+
within AudD's internal 12-second scan fragment behind them. Access to `isrc`,
|
|
156
|
+
`upc`, and `score` requires a Startup plan or higher — [contact
|
|
157
|
+
us](mailto:api@audd.io) for enterprise features.
|
|
152
158
|
|
|
153
159
|
The default per-call timeout is **1 hour** for this endpoint (60s for
|
|
154
160
|
standard recognition); override with `timeoutMs`.
|
|
@@ -268,7 +274,7 @@ app.use(express.json());
|
|
|
268
274
|
app.post("/audd-callback", async (req, res) => {
|
|
269
275
|
const { match, notification } = await handleCallback(req);
|
|
270
276
|
if (match) {
|
|
271
|
-
console.log(`${match.song
|
|
277
|
+
console.log(`${match.song?.artist ?? "?"} - ${match.song?.title ?? "?"} score=${match.song?.score ?? "?"}`);
|
|
272
278
|
for (const alt of match.alternatives) {
|
|
273
279
|
// alternatives are variant catalog releases — different artist/title is possible
|
|
274
280
|
console.log(` alt: ${alt.artist} - ${alt.title}`);
|
|
@@ -298,7 +304,7 @@ import { handleCallback } from "@audd/sdk";
|
|
|
298
304
|
const app = Fastify();
|
|
299
305
|
app.post("/audd-callback", async (req, reply) => {
|
|
300
306
|
const { match } = await handleCallback(req);
|
|
301
|
-
if (match) console.log(`${match.song
|
|
307
|
+
if (match) console.log(`${match.song?.artist ?? "?"} — ${match.song?.title ?? "?"}`);
|
|
302
308
|
return { ok: true };
|
|
303
309
|
});
|
|
304
310
|
```
|
|
@@ -317,7 +323,7 @@ const router = new Router();
|
|
|
317
323
|
app.use(bodyParser());
|
|
318
324
|
router.post("/audd-callback", async (ctx) => {
|
|
319
325
|
const { match } = await handleCallback(ctx.request);
|
|
320
|
-
if (match) console.log(`${match.song
|
|
326
|
+
if (match) console.log(`${match.song?.artist ?? "?"} — ${match.song?.title ?? "?"}`);
|
|
321
327
|
ctx.body = { ok: true };
|
|
322
328
|
});
|
|
323
329
|
app.use(router.routes());
|
|
@@ -331,7 +337,7 @@ import { handleCallback } from "@audd/sdk";
|
|
|
331
337
|
|
|
332
338
|
export async function POST(req: NextRequest) {
|
|
333
339
|
const { match } = await handleCallback(req);
|
|
334
|
-
if (match) console.log(`${match.song
|
|
340
|
+
if (match) console.log(`${match.song?.artist ?? "?"} — ${match.song?.title ?? "?"}`);
|
|
335
341
|
return NextResponse.json({ ok: true });
|
|
336
342
|
}
|
|
337
343
|
```
|
|
@@ -353,7 +359,7 @@ const radioId = 1; // any integer you choose — your handle for this stream
|
|
|
353
359
|
|
|
354
360
|
const poll = await audd.streams.longpoll({ radioId, timeout: 30 });
|
|
355
361
|
for await (const m of poll.matches) {
|
|
356
|
-
console.log(m.song
|
|
362
|
+
console.log(m.song?.artist ?? "?", m.song?.title ?? "?");
|
|
357
363
|
}
|
|
358
364
|
```
|
|
359
365
|
|
|
@@ -363,7 +369,7 @@ Consume matches and notifications concurrently:
|
|
|
363
369
|
await Promise.all([
|
|
364
370
|
(async () => {
|
|
365
371
|
for await (const m of poll.matches) {
|
|
366
|
-
console.log("match:", m.song
|
|
372
|
+
console.log("match:", m.song?.artist ?? "?", m.song?.title ?? "?");
|
|
367
373
|
}
|
|
368
374
|
})(),
|
|
369
375
|
(async () => {
|
|
@@ -396,7 +402,7 @@ import { LongpollConsumer } from "@audd/sdk/longpoll";
|
|
|
396
402
|
const consumer = new LongpollConsumer("abc123def");
|
|
397
403
|
const poll = consumer.iterate({ timeout: 30 });
|
|
398
404
|
for await (const m of poll.matches) {
|
|
399
|
-
console.log(m.song
|
|
405
|
+
console.log(m.song?.artist ?? "?", m.song?.title ?? "?");
|
|
400
406
|
}
|
|
401
407
|
```
|
|
402
408
|
|