@audd/sdk 1.5.12 → 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/dist/index.cjs +39 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +39 -14
- package/dist/index.js.map +1 -1
- package/dist/longpoll.cjs +33 -8
- package/dist/longpoll.cjs.map +1 -1
- package/dist/longpoll.js +33 -8
- package/dist/longpoll.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
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-BXx8PRmC.cjs';
|
|
2
2
|
export { E as EnterpriseChunkResult, e as StreamCallbackSong, f as StreamingProvider } from './longpollCore-BXx8PRmC.cjs';
|
|
3
3
|
|
|
4
|
-
declare const VERSION = "1.5.
|
|
4
|
+
declare const VERSION = "1.5.13";
|
|
5
5
|
|
|
6
6
|
/** Inspection events emitted around each HTTP request the SDK makes. */
|
|
7
7
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
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-BXx8PRmC.js';
|
|
2
2
|
export { E as EnterpriseChunkResult, e as StreamCallbackSong, f as StreamingProvider } from './longpollCore-BXx8PRmC.js';
|
|
3
3
|
|
|
4
|
-
declare const VERSION = "1.5.
|
|
4
|
+
declare const VERSION = "1.5.13";
|
|
5
5
|
|
|
6
6
|
/** Inspection events emitted around each HTTP request the SDK makes. */
|
|
7
7
|
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import * as path from 'path';
|
|
|
3
3
|
import { createHash } from 'crypto';
|
|
4
4
|
|
|
5
5
|
// src/version.ts
|
|
6
|
-
var VERSION = "1.5.
|
|
6
|
+
var VERSION = "1.5.13";
|
|
7
7
|
|
|
8
8
|
// src/errors.ts
|
|
9
9
|
var AudDError = class extends Error {
|
|
@@ -317,13 +317,38 @@ function asObjectLenient(raw) {
|
|
|
317
317
|
return asObject(raw) ?? {};
|
|
318
318
|
}
|
|
319
319
|
function asString(v) {
|
|
320
|
-
|
|
320
|
+
if (typeof v === "string") return v;
|
|
321
|
+
if (typeof v === "number" || typeof v === "boolean") return String(v);
|
|
322
|
+
return void 0;
|
|
323
|
+
}
|
|
324
|
+
function toFiniteNumber(v) {
|
|
325
|
+
if (typeof v === "number") return Number.isFinite(v) ? v : void 0;
|
|
326
|
+
if (typeof v === "boolean") return v ? 1 : 0;
|
|
327
|
+
if (typeof v === "string") {
|
|
328
|
+
const t = v.trim();
|
|
329
|
+
if (t === "") return void 0;
|
|
330
|
+
const n = Number(t);
|
|
331
|
+
return Number.isFinite(n) ? n : void 0;
|
|
332
|
+
}
|
|
333
|
+
return void 0;
|
|
321
334
|
}
|
|
322
335
|
function asNumber(v) {
|
|
323
|
-
return
|
|
336
|
+
return toFiniteNumber(v);
|
|
337
|
+
}
|
|
338
|
+
function asInteger(v) {
|
|
339
|
+
const n = toFiniteNumber(v);
|
|
340
|
+
return n === void 0 ? void 0 : Math.trunc(n);
|
|
324
341
|
}
|
|
325
342
|
function asBoolean(v) {
|
|
326
|
-
|
|
343
|
+
if (typeof v === "boolean") return v;
|
|
344
|
+
if (typeof v === "number") return v !== 0;
|
|
345
|
+
if (typeof v === "string") {
|
|
346
|
+
const t = v.trim().toLowerCase();
|
|
347
|
+
if (t === "true" || t === "1" || t === "yes" || t === "on") return true;
|
|
348
|
+
if (t === "false" || t === "0" || t === "no" || t === "off" || t === "") return false;
|
|
349
|
+
return void 0;
|
|
350
|
+
}
|
|
351
|
+
return void 0;
|
|
327
352
|
}
|
|
328
353
|
function parseOffsetToSeconds(o) {
|
|
329
354
|
if (o === void 0 || o === null) return void 0;
|
|
@@ -420,7 +445,7 @@ var RECOGNITION_KEYS = [
|
|
|
420
445
|
function parseRecognitionResult(raw) {
|
|
421
446
|
const r = asObjectLenient(raw);
|
|
422
447
|
const timecode = asString(r.timecode);
|
|
423
|
-
const audioId =
|
|
448
|
+
const audioId = asInteger(r.audio_id);
|
|
424
449
|
const artist = asString(r.artist);
|
|
425
450
|
const title = asString(r.title);
|
|
426
451
|
const songLink = asString(r.song_link);
|
|
@@ -508,8 +533,8 @@ function parseEnterpriseMatch(raw) {
|
|
|
508
533
|
isrc: asString(r.isrc),
|
|
509
534
|
upc: asString(r.upc),
|
|
510
535
|
songLink,
|
|
511
|
-
startOffset:
|
|
512
|
-
endOffset:
|
|
536
|
+
startOffset: asInteger(r.start_offset),
|
|
537
|
+
endOffset: asInteger(r.end_offset),
|
|
513
538
|
startSeconds: void 0,
|
|
514
539
|
endSeconds: void 0,
|
|
515
540
|
extras: pickExtras(r, ENTERPRISE_MATCH_KEYS),
|
|
@@ -565,7 +590,7 @@ function parseEnterpriseChunkResult(raw) {
|
|
|
565
590
|
var STREAM_KEYS = ["radio_id", "url", "stream_running", "longpoll_category"];
|
|
566
591
|
function parseStream(raw) {
|
|
567
592
|
const r = asObjectLenient(raw);
|
|
568
|
-
const radioId =
|
|
593
|
+
const radioId = asInteger(r.radio_id);
|
|
569
594
|
const url = asString(r.url);
|
|
570
595
|
const streamRunning = asBoolean(r.stream_running);
|
|
571
596
|
return {
|
|
@@ -625,14 +650,14 @@ var STREAM_CALLBACK_MATCH_KEYS = [
|
|
|
625
650
|
];
|
|
626
651
|
function parseStreamCallbackMatch(raw) {
|
|
627
652
|
const r = asObjectLenient(raw);
|
|
628
|
-
const radioId =
|
|
653
|
+
const radioId = asInteger(r.radio_id);
|
|
629
654
|
const resultsRaw = Array.isArray(r.results) ? r.results : [];
|
|
630
655
|
const songs = resultsRaw.filter((x) => asObject(x) !== void 0).map(parseStreamCallbackSong);
|
|
631
656
|
const [first, ...rest] = songs;
|
|
632
657
|
return {
|
|
633
658
|
radioId,
|
|
634
659
|
timestamp: asString(r.timestamp),
|
|
635
|
-
playLength:
|
|
660
|
+
playLength: asInteger(r.play_length),
|
|
636
661
|
song: first,
|
|
637
662
|
alternatives: rest,
|
|
638
663
|
extras: pickExtras(r, STREAM_CALLBACK_MATCH_KEYS),
|
|
@@ -647,8 +672,8 @@ var STREAM_CALLBACK_NOTIFICATION_KEYS = [
|
|
|
647
672
|
];
|
|
648
673
|
function parseStreamCallbackNotification(raw) {
|
|
649
674
|
const r = asObjectLenient(raw);
|
|
650
|
-
const radioId =
|
|
651
|
-
const code =
|
|
675
|
+
const radioId = asInteger(r.radio_id);
|
|
676
|
+
const code = asInteger(r.notification_code);
|
|
652
677
|
const message = asString(r.notification_message);
|
|
653
678
|
return {
|
|
654
679
|
radioId,
|
|
@@ -677,9 +702,9 @@ function parseLyricsResult(raw) {
|
|
|
677
702
|
artist,
|
|
678
703
|
title,
|
|
679
704
|
lyrics: asString(r.lyrics),
|
|
680
|
-
songId:
|
|
705
|
+
songId: asInteger(r.song_id),
|
|
681
706
|
fullTitle: asString(r.full_title),
|
|
682
|
-
artistId:
|
|
707
|
+
artistId: asInteger(r.artist_id),
|
|
683
708
|
songLink: asString(r.song_link),
|
|
684
709
|
media: asString(r.media),
|
|
685
710
|
extras: pickExtras(r, LYRICS_KEYS),
|