@audd/sdk 1.5.4 → 1.5.6
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 +2 -2
- package/dist/index.cjs +29 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +32 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.js +29 -17
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ Recognize from a URL:
|
|
|
21
21
|
```ts
|
|
22
22
|
import { AudD } from "@audd/sdk";
|
|
23
23
|
|
|
24
|
-
const audd = new AudD("
|
|
24
|
+
const audd = new AudD("your-api-token");
|
|
25
25
|
const song = await audd.recognize("https://audd.tech/example.mp3");
|
|
26
26
|
if (song) {
|
|
27
27
|
console.log(`${song.artist} — ${song.title}`);
|
|
@@ -34,7 +34,7 @@ Recognize a local file (Node):
|
|
|
34
34
|
import { AudD } from "@audd/sdk";
|
|
35
35
|
import { readFile } from "node:fs/promises";
|
|
36
36
|
|
|
37
|
-
const audd = new AudD("
|
|
37
|
+
const audd = new AudD("your-api-token");
|
|
38
38
|
|
|
39
39
|
// Pass a path…
|
|
40
40
|
const song = await audd.recognize("./clip.mp3");
|
package/dist/index.cjs
CHANGED
|
@@ -1169,30 +1169,42 @@ var Streams = class {
|
|
|
1169
1169
|
parseCallback(body) {
|
|
1170
1170
|
return parseCallback(body);
|
|
1171
1171
|
}
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1172
|
+
async longpoll(arg1, opts = {}) {
|
|
1173
|
+
let category;
|
|
1174
|
+
let effectiveOpts;
|
|
1175
|
+
if (typeof arg1 === "string") {
|
|
1176
|
+
category = arg1;
|
|
1177
|
+
effectiveOpts = opts;
|
|
1178
|
+
} else {
|
|
1179
|
+
effectiveOpts = arg1;
|
|
1180
|
+
const hasRadioId = arg1.radioId !== void 0;
|
|
1181
|
+
const hasCategory = arg1.category !== void 0;
|
|
1182
|
+
if (hasRadioId && hasCategory) {
|
|
1183
|
+
throw new AudDInvalidRequestError({
|
|
1184
|
+
errorCode: 0,
|
|
1185
|
+
message: "longpoll(): pass exactly one of `radioId` or `category` \u2014 got both.",
|
|
1186
|
+
httpStatus: 0
|
|
1187
|
+
});
|
|
1188
|
+
}
|
|
1189
|
+
if (!hasRadioId && !hasCategory) {
|
|
1190
|
+
throw new AudDInvalidRequestError({
|
|
1191
|
+
errorCode: 0,
|
|
1192
|
+
message: "longpoll(): pass exactly one of `radioId` or `category` \u2014 got neither.",
|
|
1193
|
+
httpStatus: 0
|
|
1194
|
+
});
|
|
1195
|
+
}
|
|
1196
|
+
category = hasRadioId ? this.deriveLongpollCategory(arg1.radioId) : arg1.category;
|
|
1197
|
+
}
|
|
1198
|
+
if (effectiveOpts.skipCallbackCheck !== true) {
|
|
1187
1199
|
await this.preflightCallbackUrl();
|
|
1188
1200
|
}
|
|
1189
|
-
const timeoutSec =
|
|
1201
|
+
const timeoutSec = effectiveOpts.timeout ?? 50;
|
|
1190
1202
|
const httpClient = this.http;
|
|
1191
1203
|
const readPolicy = this.readPolicy;
|
|
1192
1204
|
return startLongpoll({
|
|
1193
1205
|
category,
|
|
1194
1206
|
timeout: timeoutSec,
|
|
1195
|
-
sinceTime:
|
|
1207
|
+
sinceTime: effectiveOpts.sinceTime,
|
|
1196
1208
|
fetchOnce: (params, signal) => runRetried(
|
|
1197
1209
|
() => httpClient.get(`${API_BASE}/longpoll/`, params, { signal }),
|
|
1198
1210
|
readPolicy
|