@audd/sdk 1.5.12 → 1.5.14

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.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.12";
4
+ declare const VERSION = "1.5.14";
5
5
 
6
6
  /** Inspection events emitted around each HTTP request the SDK makes. */
7
7
 
@@ -365,8 +365,8 @@ declare class CustomCatalog {
365
365
  constructor(http: HttpClient, noRetryPolicy: RetryPolicy, onEvent?: OnEventHook | undefined);
366
366
  /**
367
367
  * **This is NOT how you submit audio for music recognition.** For
368
- * recognition, use `audd.recognize()` (or `audd.recognizeEnterprise()` for
369
- * files longer than 25 seconds). This method adds a song to your
368
+ * recognition, use `audd.recognize()` (or `audd.recognizeEnterprise()` to scan
369
+ * beyond the first 12 seconds of a file). This method adds a song to your
370
370
  * **private fingerprint catalog** so AudD's recognition can later identify
371
371
  * *your own* tracks for *your account only*. Requires special access —
372
372
  * contact api@audd.io if you need it enabled.
@@ -496,7 +496,8 @@ declare class AudD {
496
496
  /** Lyrics search + raw-request escape hatch. */
497
497
  get advanced(): Advanced;
498
498
  /**
499
- * Recognize a short audio clip (≤25s) from a URL, file path, Blob, or bytes.
499
+ * Recognize a song from an audio clip given as a URL, file path, Blob, or
500
+ * bytes; only the first 12 seconds are analyzed.
500
501
  *
501
502
  * Returns `null` when the server returns `status=success` with `result=null`
502
503
  * (no match) — distinct from a thrown error.
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.12";
4
+ declare const VERSION = "1.5.14";
5
5
 
6
6
  /** Inspection events emitted around each HTTP request the SDK makes. */
7
7
 
@@ -365,8 +365,8 @@ declare class CustomCatalog {
365
365
  constructor(http: HttpClient, noRetryPolicy: RetryPolicy, onEvent?: OnEventHook | undefined);
366
366
  /**
367
367
  * **This is NOT how you submit audio for music recognition.** For
368
- * recognition, use `audd.recognize()` (or `audd.recognizeEnterprise()` for
369
- * files longer than 25 seconds). This method adds a song to your
368
+ * recognition, use `audd.recognize()` (or `audd.recognizeEnterprise()` to scan
369
+ * beyond the first 12 seconds of a file). This method adds a song to your
370
370
  * **private fingerprint catalog** so AudD's recognition can later identify
371
371
  * *your own* tracks for *your account only*. Requires special access —
372
372
  * contact api@audd.io if you need it enabled.
@@ -496,7 +496,8 @@ declare class AudD {
496
496
  /** Lyrics search + raw-request escape hatch. */
497
497
  get advanced(): Advanced;
498
498
  /**
499
- * Recognize a short audio clip (≤25s) from a URL, file path, Blob, or bytes.
499
+ * Recognize a song from an audio clip given as a URL, file path, Blob, or
500
+ * bytes; only the first 12 seconds are analyzed.
500
501
  *
501
502
  * Returns `null` when the server returns `status=success` with `result=null`
502
503
  * (no match) — distinct from a thrown error.
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.12";
6
+ var VERSION = "1.5.14";
7
7
 
8
8
  // src/errors.ts
9
9
  var AudDError = class extends Error {
@@ -133,7 +133,7 @@ function brandedMessageOf(result) {
133
133
  if (typeof r.title === "string" && r.title.length > 0) parts.push(r.title);
134
134
  return parts.length === 0 ? null : parts.join(" \u2014 ");
135
135
  }
136
- var CUSTOM_CATALOG_PREFIX = "Adding songs to your custom catalog requires enterprise access that isn't enabled on your account.\n\nNote: the custom-catalog endpoint is for adding songs to your private fingerprint database, not for music recognition. If you intended to identify music, use recognize(...) (or recognizeEnterprise(...) for files longer than 25 seconds) instead.\n\nTo request custom-catalog access, contact api@audd.io.\n\n";
136
+ var CUSTOM_CATALOG_PREFIX = "Adding songs to your custom catalog requires enterprise access that isn't enabled on your account.\n\nNote: the custom-catalog endpoint is for adding songs to your private fingerprint database, not for music recognition. If you intended to identify music, use recognize(...) (or recognizeEnterprise(...) to scan beyond the first 12 seconds of a file) instead.\n\nTo request custom-catalog access, contact api@audd.io.\n\n";
137
137
  function raiseFromErrorResponse(body, opts) {
138
138
  const code = body.error?.error_code ?? 0;
139
139
  const message = body.error?.error_message ?? "";
@@ -317,13 +317,38 @@ function asObjectLenient(raw) {
317
317
  return asObject(raw) ?? {};
318
318
  }
319
319
  function asString(v) {
320
- return typeof v === "string" ? v : void 0;
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 typeof v === "number" ? v : void 0;
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
- return typeof v === "boolean" ? v : void 0;
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 = asNumber(r.audio_id);
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: asNumber(r.start_offset),
512
- endOffset: asNumber(r.end_offset),
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 = asNumber(r.radio_id);
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 = asNumber(r.radio_id);
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: asNumber(r.play_length),
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 = asNumber(r.radio_id);
651
- const code = asNumber(r.notification_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: asNumber(r.song_id),
705
+ songId: asInteger(r.song_id),
681
706
  fullTitle: asString(r.full_title),
682
- artistId: asNumber(r.artist_id),
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),
@@ -1325,8 +1350,8 @@ var CustomCatalog = class {
1325
1350
  onEvent;
1326
1351
  /**
1327
1352
  * **This is NOT how you submit audio for music recognition.** For
1328
- * recognition, use `audd.recognize()` (or `audd.recognizeEnterprise()` for
1329
- * files longer than 25 seconds). This method adds a song to your
1353
+ * recognition, use `audd.recognize()` (or `audd.recognizeEnterprise()` to scan
1354
+ * beyond the first 12 seconds of a file). This method adds a song to your
1330
1355
  * **private fingerprint catalog** so AudD's recognition can later identify
1331
1356
  * *your own* tracks for *your account only*. Requires special access —
1332
1357
  * contact api@audd.io if you need it enabled.
@@ -1582,7 +1607,8 @@ var AudD = class {
1582
1607
  return this._advanced;
1583
1608
  }
1584
1609
  /**
1585
- * Recognize a short audio clip (≤25s) from a URL, file path, Blob, or bytes.
1610
+ * Recognize a song from an audio clip given as a URL, file path, Blob, or
1611
+ * bytes; only the first 12 seconds are analyzed.
1586
1612
  *
1587
1613
  * Returns `null` when the server returns `status=success` with `result=null`
1588
1614
  * (no match) — distinct from a thrown error.