@audd/sdk 1.5.8 → 1.5.10

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 CHANGED
@@ -85,7 +85,7 @@ console.log(song.releaseDate, song.label, song.timecode);
85
85
  // AudD's universal song page — links into every provider
86
86
  console.log(song.songLink);
87
87
 
88
- // Helpers — driven off songLink, work without any `return` opt-in
88
+ // Helpers — driven off songLink, work without any `returnMetadata` opt-in
89
89
  console.log(song.thumbnailUrl); // cover-art image, or null
90
90
  console.log(song.streamingUrl("spotify")); // direct or lis.tn redirect
91
91
  console.log(song.streamingUrls()); // map of provider -> URL
@@ -107,21 +107,21 @@ Valid `returnMetadata` values: `apple_music`, `spotify`, `deezer`, `napster`,
107
107
  `musicbrainz`. Blocks are `undefined` when not requested.
108
108
 
109
109
  `streamingUrl(provider)` prefers the direct provider URL when you
110
- requested that block via `return`, then falls back to the lis.tn redirect
110
+ requested that block via `returnMetadata`, then falls back to the lis.tn redirect
111
111
  when `songLink` is on `lis.tn`. YouTube has only the redirect path.
112
112
 
113
113
  ## Reading additional metadata
114
114
 
115
115
  Every model carries an `extras` map with any server-side fields outside
116
116
  the typed surface, plus a `rawResponse` of the full unparsed JSON. Use
117
- `extras` to read undocumented or beta fields:
117
+ `extras` to read fields outside the typed surface:
118
118
 
119
119
  ```ts
120
120
  console.log(song.extras); // any non-typed top-level fields
121
121
  console.log(song.rawResponse); // the whole result object as the server returned it
122
122
  ```
123
123
 
124
- For the **request** side, every call accepts an `extraParameters` map for additional form fields the typed options don't cover — undocumented parameters or beta features:
124
+ For the **request** side, every call accepts an `extraParameters` map for additional form fields the typed options don't cover:
125
125
 
126
126
  ```ts
127
127
  await audd.recognize(url, {
package/dist/index.cjs CHANGED
@@ -366,9 +366,6 @@ var RECOGNITION_KEYS = [
366
366
  function parseRecognitionResult(raw) {
367
367
  const r = requireObject(raw, "RecognitionResult");
368
368
  const timecode = asString(r.timecode);
369
- if (timecode === void 0) {
370
- throw new TypeError("RecognitionResult: timecode missing or not string");
371
- }
372
369
  const audioId = asNumber(r.audio_id);
373
370
  const artist = asString(r.artist);
374
371
  const title = asString(r.title);
@@ -443,8 +440,6 @@ function parseEnterpriseMatch(raw) {
443
440
  const r = requireObject(raw, "EnterpriseMatch");
444
441
  const score = asNumber(r.score);
445
442
  const timecode = asString(r.timecode);
446
- if (score === void 0) throw new TypeError("EnterpriseMatch: score not number");
447
- if (timecode === void 0) throw new TypeError("EnterpriseMatch: timecode not string");
448
443
  const songLink = asString(r.song_link);
449
444
  return {
450
445
  score,
@@ -491,12 +486,8 @@ function parseEnterpriseMatch(raw) {
491
486
  var ENTERPRISE_CHUNK_KEYS = ["songs", "offset"];
492
487
  function parseEnterpriseChunkResult(raw) {
493
488
  const r = requireObject(raw, "EnterpriseChunkResult");
494
- const songsRaw = r.songs;
495
- if (!Array.isArray(songsRaw)) {
496
- throw new TypeError("EnterpriseChunkResult: songs not array");
497
- }
489
+ const songsRaw = Array.isArray(r.songs) ? r.songs : [];
498
490
  const offset = asString(r.offset);
499
- if (offset === void 0) throw new TypeError("EnterpriseChunkResult: offset not string");
500
491
  return {
501
492
  songs: songsRaw.map(parseEnterpriseMatch),
502
493
  offset,
@@ -510,9 +501,6 @@ function parseStream(raw) {
510
501
  const radioId = asNumber(r.radio_id);
511
502
  const url = asString(r.url);
512
503
  const streamRunning = asBoolean(r.stream_running);
513
- if (radioId === void 0) throw new TypeError("Stream: radio_id not number");
514
- if (url === void 0) throw new TypeError("Stream: url not string");
515
- if (streamRunning === void 0) throw new TypeError("Stream: stream_running not boolean");
516
504
  return {
517
505
  radioId,
518
506
  url,
@@ -543,9 +531,6 @@ function parseStreamCallbackSong(raw) {
543
531
  const artist = asString(r.artist);
544
532
  const title = asString(r.title);
545
533
  const score = asNumber(r.score);
546
- if (artist === void 0) throw new TypeError("StreamCallbackSong: artist not string");
547
- if (title === void 0) throw new TypeError("StreamCallbackSong: title not string");
548
- if (score === void 0) throw new TypeError("StreamCallbackSong: score not number");
549
534
  const musicbrainz = Array.isArray(r.musicbrainz) ? r.musicbrainz.filter((x) => asObject(x) !== void 0) : void 0;
550
535
  return {
551
536
  artist,
@@ -574,13 +559,9 @@ var STREAM_CALLBACK_MATCH_KEYS = [
574
559
  function parseStreamCallbackMatch(raw) {
575
560
  const r = requireObject(raw, "StreamCallbackMatch");
576
561
  const radioId = asNumber(r.radio_id);
577
- if (radioId === void 0) throw new TypeError("StreamCallbackMatch: radio_id not number");
578
- const resultsRaw = r.results;
579
- if (!Array.isArray(resultsRaw)) throw new TypeError("StreamCallbackMatch: results not array");
580
- if (resultsRaw.length === 0) throw new TypeError("StreamCallbackMatch: results is empty");
581
- const songs = resultsRaw.map(parseStreamCallbackSong);
562
+ const resultsRaw = Array.isArray(r.results) ? r.results : [];
563
+ const songs = resultsRaw.filter((x) => asObject(x) !== void 0).map(parseStreamCallbackSong);
582
564
  const [first, ...rest] = songs;
583
- if (first === void 0) throw new TypeError("StreamCallbackMatch: results is empty");
584
565
  return {
585
566
  radioId,
586
567
  timestamp: asString(r.timestamp),
@@ -600,14 +581,8 @@ var STREAM_CALLBACK_NOTIFICATION_KEYS = [
600
581
  function parseStreamCallbackNotification(raw) {
601
582
  const r = requireObject(raw, "StreamCallbackNotification");
602
583
  const radioId = asNumber(r.radio_id);
603
- if (radioId === void 0)
604
- throw new TypeError("StreamCallbackNotification: radio_id not number");
605
584
  const code = asNumber(r.notification_code);
606
- if (code === void 0)
607
- throw new TypeError("StreamCallbackNotification: notification_code not number");
608
585
  const message = asString(r.notification_message);
609
- if (message === void 0)
610
- throw new TypeError("StreamCallbackNotification: notification_message not string");
611
586
  return {
612
587
  radioId,
613
588
  streamRunning: asBoolean(r.stream_running),
@@ -631,8 +606,6 @@ function parseLyricsResult(raw) {
631
606
  const r = requireObject(raw, "LyricsResult");
632
607
  const artist = asString(r.artist);
633
608
  const title = asString(r.title);
634
- if (artist === void 0) throw new TypeError("LyricsResult: artist not string");
635
- if (title === void 0) throw new TypeError("LyricsResult: title not string");
636
609
  return {
637
610
  artist,
638
611
  title,