@audd/sdk 1.5.10 → 1.5.11
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 -4
- package/dist/index.cjs +31 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +31 -4
- package/dist/index.js.map +1 -1
- package/dist/longpoll.cjs.map +1 -1
- package/dist/longpoll.d.cts +1 -1
- package/dist/longpoll.d.ts +1 -1
- package/dist/longpoll.js.map +1 -1
- package/dist/{longpollCore-BRyps2P4.d.cts → longpollCore-ZtFOyojP.d.cts} +7 -4
- package/dist/{longpollCore-BRyps2P4.d.ts → longpollCore-ZtFOyojP.d.ts} +7 -4
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as StreamCallbackMatch, d as StreamCallbackNotification, H as HttpClient, S as Stream, L as LongpollPoll, b as LyricsResult, F as FetchLike, R as RecognitionResult, a as EnterpriseMatch } from './longpollCore-
|
|
2
|
-
export { E as EnterpriseChunkResult, e as StreamCallbackSong, f as StreamingProvider } from './longpollCore-
|
|
1
|
+
import { c as StreamCallbackMatch, d as StreamCallbackNotification, H as HttpClient, S as Stream, L as LongpollPoll, b as LyricsResult, F as FetchLike, R as RecognitionResult, a as EnterpriseMatch } from './longpollCore-ZtFOyojP.cjs';
|
|
2
|
+
export { E as EnterpriseChunkResult, e as StreamCallbackSong, f as StreamingProvider } from './longpollCore-ZtFOyojP.cjs';
|
|
3
3
|
|
|
4
4
|
declare const VERSION = "1.5.8";
|
|
5
5
|
|
|
@@ -431,6 +431,7 @@ interface RecognizeEnterpriseOptions {
|
|
|
431
431
|
limit?: number;
|
|
432
432
|
skipFirstSeconds?: number;
|
|
433
433
|
useTimecode?: boolean;
|
|
434
|
+
/** Request precise within-fragment offsets. Defaults to `true`; pass `false` to opt out. */
|
|
434
435
|
accurateOffsets?: boolean;
|
|
435
436
|
timeoutMs?: number;
|
|
436
437
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as StreamCallbackMatch, d as StreamCallbackNotification, H as HttpClient, S as Stream, L as LongpollPoll, b as LyricsResult, F as FetchLike, R as RecognitionResult, a as EnterpriseMatch } from './longpollCore-
|
|
2
|
-
export { E as EnterpriseChunkResult, e as StreamCallbackSong, f as StreamingProvider } from './longpollCore-
|
|
1
|
+
import { c as StreamCallbackMatch, d as StreamCallbackNotification, H as HttpClient, S as Stream, L as LongpollPoll, b as LyricsResult, F as FetchLike, R as RecognitionResult, a as EnterpriseMatch } from './longpollCore-ZtFOyojP.js';
|
|
2
|
+
export { E as EnterpriseChunkResult, e as StreamCallbackSong, f as StreamingProvider } from './longpollCore-ZtFOyojP.js';
|
|
3
3
|
|
|
4
4
|
declare const VERSION = "1.5.8";
|
|
5
5
|
|
|
@@ -431,6 +431,7 @@ interface RecognizeEnterpriseOptions {
|
|
|
431
431
|
limit?: number;
|
|
432
432
|
skipFirstSeconds?: number;
|
|
433
433
|
useTimecode?: boolean;
|
|
434
|
+
/** Request precise within-fragment offsets. Defaults to `true`; pass `false` to opt out. */
|
|
434
435
|
accurateOffsets?: boolean;
|
|
435
436
|
timeoutMs?: number;
|
|
436
437
|
/**
|
package/dist/index.js
CHANGED
|
@@ -263,6 +263,20 @@ function asNumber(v) {
|
|
|
263
263
|
function asBoolean(v) {
|
|
264
264
|
return typeof v === "boolean" ? v : void 0;
|
|
265
265
|
}
|
|
266
|
+
function parseOffsetToSeconds(o) {
|
|
267
|
+
if (o === void 0 || o === null) return void 0;
|
|
268
|
+
if (typeof o === "number") return Number.isFinite(o) ? o : void 0;
|
|
269
|
+
const t = String(o).trim();
|
|
270
|
+
if (t === "") return void 0;
|
|
271
|
+
let total = 0;
|
|
272
|
+
for (const part of t.split(":")) {
|
|
273
|
+
if (part.trim() === "") return void 0;
|
|
274
|
+
const n = Number(part);
|
|
275
|
+
if (!Number.isFinite(n)) return void 0;
|
|
276
|
+
total = total * 60 + n;
|
|
277
|
+
}
|
|
278
|
+
return total;
|
|
279
|
+
}
|
|
266
280
|
var STREAMING_PROVIDERS = [
|
|
267
281
|
"spotify",
|
|
268
282
|
"apple_music",
|
|
@@ -412,7 +426,9 @@ var ENTERPRISE_MATCH_KEYS = [
|
|
|
412
426
|
"upc",
|
|
413
427
|
"song_link",
|
|
414
428
|
"start_offset",
|
|
415
|
-
"end_offset"
|
|
429
|
+
"end_offset",
|
|
430
|
+
"start_seconds",
|
|
431
|
+
"end_seconds"
|
|
416
432
|
];
|
|
417
433
|
function parseEnterpriseMatch(raw) {
|
|
418
434
|
const r = requireObject(raw, "EnterpriseMatch");
|
|
@@ -432,6 +448,8 @@ function parseEnterpriseMatch(raw) {
|
|
|
432
448
|
songLink,
|
|
433
449
|
startOffset: asNumber(r.start_offset),
|
|
434
450
|
endOffset: asNumber(r.end_offset),
|
|
451
|
+
startSeconds: void 0,
|
|
452
|
+
endSeconds: void 0,
|
|
435
453
|
extras: pickExtras(r, ENTERPRISE_MATCH_KEYS),
|
|
436
454
|
rawResponse: r,
|
|
437
455
|
streamingUrl(provider) {
|
|
@@ -466,8 +484,17 @@ function parseEnterpriseChunkResult(raw) {
|
|
|
466
484
|
const r = requireObject(raw, "EnterpriseChunkResult");
|
|
467
485
|
const songsRaw = Array.isArray(r.songs) ? r.songs : [];
|
|
468
486
|
const offset = asString(r.offset);
|
|
487
|
+
const base = parseOffsetToSeconds(r.offset);
|
|
488
|
+
const songs = songsRaw.map((s) => {
|
|
489
|
+
const match = parseEnterpriseMatch(s);
|
|
490
|
+
if (base !== void 0) {
|
|
491
|
+
match.startSeconds = base + (match.startOffset ?? 0) / 1e3;
|
|
492
|
+
match.endSeconds = base + (match.endOffset ?? 0) / 1e3;
|
|
493
|
+
}
|
|
494
|
+
return match;
|
|
495
|
+
});
|
|
469
496
|
return {
|
|
470
|
-
songs
|
|
497
|
+
songs,
|
|
471
498
|
offset,
|
|
472
499
|
extras: pickExtras(r, ENTERPRISE_CHUNK_KEYS),
|
|
473
500
|
rawResponse: r
|
|
@@ -1354,8 +1381,8 @@ function buildEnterpriseFields(opts) {
|
|
|
1354
1381
|
if (opts.skipFirstSeconds !== void 0)
|
|
1355
1382
|
fields["skip_first_seconds"] = String(opts.skipFirstSeconds);
|
|
1356
1383
|
if (opts.useTimecode !== void 0) fields["use_timecode"] = opts.useTimecode ? "true" : "false";
|
|
1357
|
-
|
|
1358
|
-
|
|
1384
|
+
const accurate = opts.accurateOffsets ?? true;
|
|
1385
|
+
fields["accurate_offsets"] = accurate ? "true" : "false";
|
|
1359
1386
|
return fields;
|
|
1360
1387
|
}
|
|
1361
1388
|
function isDeprecationPassThrough(body) {
|