playlist-data-engine 1.7.0 → 1.7.2
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/core/parser/PlaylistParser.d.ts.map +1 -1
- package/dist/core/types/Playlist.d.ts +8 -0
- package/dist/core/types/Playlist.d.ts.map +1 -1
- package/dist/gateway-DUk4nCao.cjs +1 -0
- package/dist/{gateway-PjLtANkX.js → gateway-DyR4M-uH.js} +273 -254
- package/dist/gateway.js +1 -1
- package/dist/gateway.mjs +1 -1
- package/dist/playlist-data-engine.js +6 -6
- package/dist/playlist-data-engine.mjs +53 -53
- package/dist/utils/ipfsUtils.d.ts +7 -0
- package/dist/utils/ipfsUtils.d.ts.map +1 -1
- package/dist/utils/playlistUtils.d.ts +6 -0
- package/dist/utils/playlistUtils.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/gateway-CtmUPK4J.cjs +0 -1
|
@@ -11,10 +11,10 @@ class n {
|
|
|
11
11
|
* 7. multimedia_url (Alternative media field)
|
|
12
12
|
*/
|
|
13
13
|
static extractAudioUrl(t) {
|
|
14
|
-
const
|
|
15
|
-
for (const
|
|
16
|
-
if (t[
|
|
17
|
-
return t[
|
|
14
|
+
const r = ["mp3_url", "mp3Url", "lossy_audio", "lossyAudio", "audio_url", "audioUrl", "audio", "lossless_audio", "losslessAudio", "animation_url", "animationUrl", "multimedia_url", "multimediaUrl"];
|
|
15
|
+
for (const e of r)
|
|
16
|
+
if (t[e] && typeof t[e] == "string")
|
|
17
|
+
return t[e];
|
|
18
18
|
return null;
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
@@ -23,10 +23,10 @@ class n {
|
|
|
23
23
|
* that back rather than null.
|
|
24
24
|
*/
|
|
25
25
|
static extractAudioUrlLossless(t) {
|
|
26
|
-
const
|
|
27
|
-
for (const
|
|
28
|
-
if (t[
|
|
29
|
-
return t[
|
|
26
|
+
const r = ["lossless_audio", "losslessAudio", "wav_url", "wavUrl", "flac_url", "flacUrl", "audio_url", "audioUrl"];
|
|
27
|
+
for (const e of r)
|
|
28
|
+
if (t[e] && typeof t[e] == "string")
|
|
29
|
+
return t[e];
|
|
30
30
|
return null;
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
@@ -47,16 +47,16 @@ class n {
|
|
|
47
47
|
* 10. primaryMedia.uri (Primary media field)
|
|
48
48
|
*/
|
|
49
49
|
static extractImageUrl(t) {
|
|
50
|
-
const
|
|
51
|
-
for (const s of
|
|
50
|
+
const r = ["image_small", "imageSmall", "image", "image_large", "imageLarge", "image_thumb", "imageThumb", "image_url", "imageUrl", "image_uri", "imageUri", "image_preview", "imagePreview"];
|
|
51
|
+
for (const s of r)
|
|
52
52
|
if (t[s] && typeof t[s] == "string")
|
|
53
53
|
return t[s];
|
|
54
|
-
const
|
|
54
|
+
const e = [
|
|
55
55
|
this.extractNestedUri(t, "artwork", "uri"),
|
|
56
56
|
this.extractNestedUri(t, "project", "artwork", "uri"),
|
|
57
57
|
this.extractNestedUri(t, "primaryMedia", "uri")
|
|
58
58
|
];
|
|
59
|
-
for (const s of
|
|
59
|
+
for (const s of e)
|
|
60
60
|
if (s) return s;
|
|
61
61
|
return null;
|
|
62
62
|
}
|
|
@@ -84,16 +84,16 @@ class n {
|
|
|
84
84
|
* 4. OpenSea-style attributes array with trait_type "Artist"
|
|
85
85
|
*/
|
|
86
86
|
static extractArtist(t) {
|
|
87
|
-
const
|
|
88
|
-
for (const
|
|
89
|
-
if (t[
|
|
90
|
-
return t[
|
|
87
|
+
const r = ["artist", "artist_name", "artistName", "album_artist", "albumArtist", "created_by", "createdBy", "minter"];
|
|
88
|
+
for (const e of r)
|
|
89
|
+
if (t[e] && typeof t[e] == "string")
|
|
90
|
+
return t[e];
|
|
91
91
|
if (Array.isArray(t.attributes)) {
|
|
92
|
-
const
|
|
92
|
+
const e = t.attributes.find(
|
|
93
93
|
(s) => s.trait_type?.toLowerCase() === "artist" && s.value !== void 0
|
|
94
94
|
);
|
|
95
|
-
if (
|
|
96
|
-
return
|
|
95
|
+
if (e && typeof e.value == "string")
|
|
96
|
+
return e.value;
|
|
97
97
|
}
|
|
98
98
|
return null;
|
|
99
99
|
}
|
|
@@ -108,11 +108,11 @@ class n {
|
|
|
108
108
|
return t;
|
|
109
109
|
if (typeof t == "string")
|
|
110
110
|
try {
|
|
111
|
-
const
|
|
112
|
-
if (typeof
|
|
113
|
-
return
|
|
114
|
-
} catch (
|
|
115
|
-
return console.warn("Failed to parse metadata:",
|
|
111
|
+
const r = JSON.parse(t);
|
|
112
|
+
if (typeof r == "object" && !Array.isArray(r))
|
|
113
|
+
return r;
|
|
114
|
+
} catch (r) {
|
|
115
|
+
return console.warn("Failed to parse metadata:", r), null;
|
|
116
116
|
}
|
|
117
117
|
return null;
|
|
118
118
|
}
|
|
@@ -131,33 +131,33 @@ class n {
|
|
|
131
131
|
if (typeof t.genre == "string")
|
|
132
132
|
return t.genre;
|
|
133
133
|
if (Array.isArray(t.genre) && t.genre.length > 0) {
|
|
134
|
-
const
|
|
135
|
-
return typeof
|
|
134
|
+
const e = t.genre[0];
|
|
135
|
+
return typeof e == "string" ? e : "";
|
|
136
136
|
}
|
|
137
137
|
if (Array.isArray(t.attributes)) {
|
|
138
|
-
const
|
|
138
|
+
const e = t.attributes.find(
|
|
139
139
|
(s) => s.trait_type?.toLowerCase() === "genre" && s.value !== void 0
|
|
140
140
|
);
|
|
141
|
-
if (
|
|
142
|
-
if (typeof
|
|
143
|
-
return
|
|
144
|
-
if (Array.isArray(
|
|
145
|
-
const s =
|
|
141
|
+
if (e) {
|
|
142
|
+
if (typeof e.value == "string")
|
|
143
|
+
return e.value;
|
|
144
|
+
if (Array.isArray(e.value) && e.value.length > 0) {
|
|
145
|
+
const s = e.value[0];
|
|
146
146
|
return typeof s == "string" ? s : "";
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
150
|
if (t.attributes && typeof t.attributes == "object" && !Array.isArray(t.attributes)) {
|
|
151
|
-
const
|
|
152
|
-
for (const s of Object.keys(
|
|
153
|
-
if (s.toLowerCase() === "genre" && typeof
|
|
154
|
-
return
|
|
151
|
+
const e = t.attributes;
|
|
152
|
+
for (const s of Object.keys(e))
|
|
153
|
+
if (s.toLowerCase() === "genre" && typeof e[s] == "string")
|
|
154
|
+
return e[s];
|
|
155
155
|
}
|
|
156
|
-
const
|
|
157
|
-
if (
|
|
158
|
-
const
|
|
159
|
-
if (typeof
|
|
160
|
-
return
|
|
156
|
+
const r = t["attribute "];
|
|
157
|
+
if (r && typeof r == "object" && !Array.isArray(r)) {
|
|
158
|
+
const e = r.genre;
|
|
159
|
+
if (typeof e == "string")
|
|
160
|
+
return e;
|
|
161
161
|
}
|
|
162
162
|
return "";
|
|
163
163
|
}
|
|
@@ -171,29 +171,29 @@ class n {
|
|
|
171
171
|
* - `attributes` as an object keyed by trait name (e.g. `attributes.Tags`)
|
|
172
172
|
*/
|
|
173
173
|
static extractTags(t) {
|
|
174
|
-
const
|
|
175
|
-
if (Array.isArray(t.tags) ?
|
|
176
|
-
const
|
|
177
|
-
Array.isArray(
|
|
174
|
+
const r = [];
|
|
175
|
+
if (Array.isArray(t.tags) ? r.push(...t.tags) : typeof t.tags == "string" && r.push(...t.tags.split(",")), t.properties && typeof t.properties == "object" && !Array.isArray(t.properties)) {
|
|
176
|
+
const e = t.properties.tags;
|
|
177
|
+
Array.isArray(e) ? r.push(...e) : typeof e == "string" && r.push(...e.split(","));
|
|
178
178
|
}
|
|
179
179
|
if (Array.isArray(t.attributes))
|
|
180
|
-
for (const
|
|
181
|
-
if (!
|
|
182
|
-
const s =
|
|
180
|
+
for (const e of t.attributes) {
|
|
181
|
+
if (!e || typeof e != "object") continue;
|
|
182
|
+
const s = e.trait_type;
|
|
183
183
|
if (typeof s == "string" && s.toLowerCase().match(/^tags?$/)) {
|
|
184
|
-
const
|
|
185
|
-
Array.isArray(
|
|
184
|
+
const a = e.value;
|
|
185
|
+
Array.isArray(a) ? r.push(...a) : typeof a == "string" && r.push(...a.split(","));
|
|
186
186
|
}
|
|
187
187
|
}
|
|
188
188
|
else if (t.attributes && typeof t.attributes == "object") {
|
|
189
|
-
const
|
|
190
|
-
for (const s of Object.keys(
|
|
189
|
+
const e = t.attributes;
|
|
190
|
+
for (const s of Object.keys(e))
|
|
191
191
|
if (s.toLowerCase().match(/^tags?$/)) {
|
|
192
|
-
const
|
|
193
|
-
Array.isArray(
|
|
192
|
+
const a = e[s];
|
|
193
|
+
Array.isArray(a) ? r.push(...a) : typeof a == "string" && r.push(...a.split(","));
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
|
-
return n.normalizeTags(
|
|
196
|
+
return n.normalizeTags(r);
|
|
197
197
|
}
|
|
198
198
|
/**
|
|
199
199
|
* Extract track description with priority:
|
|
@@ -213,16 +213,16 @@ class n {
|
|
|
213
213
|
* descriptions, not the track's.
|
|
214
214
|
*/
|
|
215
215
|
static extractDescription(t) {
|
|
216
|
-
const
|
|
217
|
-
for (const
|
|
218
|
-
if (t[
|
|
219
|
-
return t[
|
|
216
|
+
const r = ["description", "track_description", "trackDescription", "description_text", "descriptionText", "desc", "blurb"];
|
|
217
|
+
for (const e of r)
|
|
218
|
+
if (t[e] && typeof t[e] == "string")
|
|
219
|
+
return t[e];
|
|
220
220
|
if (Array.isArray(t.attributes)) {
|
|
221
|
-
const
|
|
221
|
+
const e = t.attributes.find(
|
|
222
222
|
(s) => s.trait_type?.toLowerCase() === "description" && typeof s.value == "string"
|
|
223
223
|
);
|
|
224
|
-
if (
|
|
225
|
-
return
|
|
224
|
+
if (e && typeof e.value == "string")
|
|
225
|
+
return e.value;
|
|
226
226
|
}
|
|
227
227
|
return n.deepFindString(t, /description/i);
|
|
228
228
|
}
|
|
@@ -240,12 +240,12 @@ class n {
|
|
|
240
240
|
* the track's own description to the album.
|
|
241
241
|
*/
|
|
242
242
|
static extractAlbumDescription(t) {
|
|
243
|
-
const
|
|
244
|
-
for (const s of
|
|
243
|
+
const r = ["album_description", "albumDescription"];
|
|
244
|
+
for (const s of r)
|
|
245
245
|
if (t[s] && typeof t[s] == "string")
|
|
246
246
|
return t[s];
|
|
247
|
-
const
|
|
248
|
-
return
|
|
247
|
+
const e = t.album;
|
|
248
|
+
return e && typeof e == "object" && !Array.isArray(e) ? n.deepFindString(e, /description|liner|notes/i) : null;
|
|
249
249
|
}
|
|
250
250
|
/**
|
|
251
251
|
* Extract artist description — one of the bonus flavors. Priority:
|
|
@@ -262,12 +262,12 @@ class n {
|
|
|
262
262
|
* track's own description to the artist.
|
|
263
263
|
*/
|
|
264
264
|
static extractArtistDescription(t) {
|
|
265
|
-
const
|
|
266
|
-
for (const s of
|
|
265
|
+
const r = ["artist_description", "artistDescription", "artist_bio", "artistBio"];
|
|
266
|
+
for (const s of r)
|
|
267
267
|
if (t[s] && typeof t[s] == "string")
|
|
268
268
|
return t[s];
|
|
269
|
-
const
|
|
270
|
-
return
|
|
269
|
+
const e = t.artist;
|
|
270
|
+
return e && typeof e == "object" && !Array.isArray(e) ? n.deepFindString(e, /description|bio|about/i) : null;
|
|
271
271
|
}
|
|
272
272
|
/**
|
|
273
273
|
* Breadth-first search for the shallowest string value whose key matches
|
|
@@ -275,19 +275,19 @@ class n {
|
|
|
275
275
|
* then key order. Objects are descended (arrays skipped), depth-capped so
|
|
276
276
|
* pathological metadata blobs stay cheap.
|
|
277
277
|
*/
|
|
278
|
-
static deepFindString(t,
|
|
279
|
-
const s = /* @__PURE__ */ new Set(),
|
|
280
|
-
for (;
|
|
281
|
-
const { node: u, depth: c } =
|
|
282
|
-
for (const
|
|
283
|
-
const
|
|
284
|
-
if (typeof
|
|
285
|
-
return
|
|
278
|
+
static deepFindString(t, r, e = 5) {
|
|
279
|
+
const s = /* @__PURE__ */ new Set(), a = [{ node: t, depth: 0 }];
|
|
280
|
+
for (; a.length > 0; ) {
|
|
281
|
+
const { node: u, depth: c } = a.shift();
|
|
282
|
+
for (const f of Object.keys(u)) {
|
|
283
|
+
const o = u[f];
|
|
284
|
+
if (typeof o == "string" && o && r.test(f))
|
|
285
|
+
return o;
|
|
286
286
|
}
|
|
287
|
-
if (!(c >=
|
|
288
|
-
for (const
|
|
289
|
-
const
|
|
290
|
-
|
|
287
|
+
if (!(c >= e))
|
|
288
|
+
for (const f of Object.keys(u)) {
|
|
289
|
+
const o = u[f];
|
|
290
|
+
o && typeof o == "object" && !Array.isArray(o) && !s.has(o) && (s.add(o), a.push({ node: o, depth: c + 1 }));
|
|
291
291
|
}
|
|
292
292
|
}
|
|
293
293
|
return null;
|
|
@@ -297,37 +297,37 @@ class n {
|
|
|
297
297
|
* trimmed string[] with empties removed.
|
|
298
298
|
*/
|
|
299
299
|
static normalizeTags(t) {
|
|
300
|
-
const
|
|
301
|
-
for (const
|
|
302
|
-
if (
|
|
303
|
-
const s = String(
|
|
304
|
-
s &&
|
|
300
|
+
const r = /* @__PURE__ */ new Set();
|
|
301
|
+
for (const e of t) {
|
|
302
|
+
if (e == null) continue;
|
|
303
|
+
const s = String(e).trim().toLowerCase();
|
|
304
|
+
s && r.add(s);
|
|
305
305
|
}
|
|
306
|
-
return Array.from(
|
|
306
|
+
return Array.from(r);
|
|
307
307
|
}
|
|
308
308
|
static convertAttributes(t) {
|
|
309
309
|
if (!Array.isArray(t))
|
|
310
310
|
return null;
|
|
311
|
-
const
|
|
312
|
-
for (const
|
|
313
|
-
|
|
314
|
-
return Object.keys(
|
|
311
|
+
const r = {};
|
|
312
|
+
for (const e of t)
|
|
313
|
+
e.trait_type && e.value !== void 0 && (r[e.trait_type] = e.value);
|
|
314
|
+
return Object.keys(r).length > 0 ? r : null;
|
|
315
315
|
}
|
|
316
316
|
/**
|
|
317
317
|
* Safely extract a URI string from a nested object path.
|
|
318
318
|
* e.g. extractNestedUri(data, 'project', 'artwork', 'uri') => data.project.artwork.uri
|
|
319
319
|
*/
|
|
320
|
-
static extractNestedUri(t, ...
|
|
321
|
-
let
|
|
322
|
-
for (const s of
|
|
323
|
-
if (
|
|
324
|
-
|
|
320
|
+
static extractNestedUri(t, ...r) {
|
|
321
|
+
let e = t;
|
|
322
|
+
for (const s of r)
|
|
323
|
+
if (e && typeof e == "object" && !Array.isArray(e))
|
|
324
|
+
e = e[s];
|
|
325
325
|
else
|
|
326
326
|
return null;
|
|
327
|
-
return typeof
|
|
327
|
+
return typeof e == "string" ? e : null;
|
|
328
328
|
}
|
|
329
329
|
}
|
|
330
|
-
function
|
|
330
|
+
function _(i) {
|
|
331
331
|
if ("audio_url" in i && typeof i.audio_url == "string")
|
|
332
332
|
return i.audio_url;
|
|
333
333
|
if ("metadata" in i) {
|
|
@@ -337,7 +337,7 @@ function m(i) {
|
|
|
337
337
|
}
|
|
338
338
|
return null;
|
|
339
339
|
}
|
|
340
|
-
function
|
|
340
|
+
function A(i) {
|
|
341
341
|
if ("audio_url_lossless" in i && typeof i.audio_url_lossless == "string")
|
|
342
342
|
return i.audio_url_lossless;
|
|
343
343
|
if ("metadata" in i) {
|
|
@@ -359,7 +359,7 @@ function g(i) {
|
|
|
359
359
|
}
|
|
360
360
|
return null;
|
|
361
361
|
}
|
|
362
|
-
function
|
|
362
|
+
function y(i) {
|
|
363
363
|
if ("image_thumb_url" in i && typeof i.image_thumb_url == "string")
|
|
364
364
|
return i.image_thumb_url;
|
|
365
365
|
if ("metadata" in i) {
|
|
@@ -369,7 +369,7 @@ function d(i) {
|
|
|
369
369
|
}
|
|
370
370
|
return null;
|
|
371
371
|
}
|
|
372
|
-
function
|
|
372
|
+
function h(i) {
|
|
373
373
|
if ("metadata" in i) {
|
|
374
374
|
const t = n.parseMetadata(i.metadata);
|
|
375
375
|
if (t && typeof t.vrm == "string" && t.vrm)
|
|
@@ -377,201 +377,205 @@ function _(i) {
|
|
|
377
377
|
}
|
|
378
378
|
return "extras" in i && i.extras && typeof i.extras.vrm == "string" && i.extras.vrm || null;
|
|
379
379
|
}
|
|
380
|
-
function
|
|
380
|
+
function M(i) {
|
|
381
381
|
const t = [];
|
|
382
|
-
for (const
|
|
383
|
-
const
|
|
384
|
-
|
|
382
|
+
for (const r of i.tracks) {
|
|
383
|
+
const e = _(r);
|
|
384
|
+
e && t.push(e);
|
|
385
385
|
}
|
|
386
386
|
return t;
|
|
387
387
|
}
|
|
388
|
-
function
|
|
388
|
+
function j(i) {
|
|
389
389
|
const t = [];
|
|
390
|
-
for (const
|
|
391
|
-
const
|
|
392
|
-
|
|
390
|
+
for (const r of i.tracks) {
|
|
391
|
+
const e = g(r);
|
|
392
|
+
e && t.push(e);
|
|
393
393
|
}
|
|
394
394
|
return t;
|
|
395
395
|
}
|
|
396
|
-
function
|
|
396
|
+
function F(i) {
|
|
397
397
|
const t = [];
|
|
398
|
-
for (const
|
|
399
|
-
if ("title" in
|
|
400
|
-
t.push(
|
|
398
|
+
for (const r of i.tracks) {
|
|
399
|
+
if ("title" in r && typeof r.title == "string") {
|
|
400
|
+
t.push(r.title);
|
|
401
401
|
continue;
|
|
402
402
|
}
|
|
403
|
-
if ("metadata" in
|
|
404
|
-
const
|
|
405
|
-
if (
|
|
406
|
-
const s = n.extractTitle(
|
|
403
|
+
if ("metadata" in r) {
|
|
404
|
+
const e = n.parseMetadata(r.metadata);
|
|
405
|
+
if (e) {
|
|
406
|
+
const s = n.extractTitle(e);
|
|
407
407
|
s && t.push(s);
|
|
408
408
|
}
|
|
409
409
|
}
|
|
410
410
|
}
|
|
411
411
|
return t;
|
|
412
412
|
}
|
|
413
|
-
function
|
|
413
|
+
function $(i) {
|
|
414
414
|
const t = [];
|
|
415
|
-
for (const
|
|
416
|
-
if ("artist" in
|
|
417
|
-
t.push(
|
|
415
|
+
for (const r of i.tracks) {
|
|
416
|
+
if ("artist" in r && typeof r.artist == "string") {
|
|
417
|
+
t.push(r.artist);
|
|
418
418
|
continue;
|
|
419
419
|
}
|
|
420
|
-
if ("metadata" in
|
|
421
|
-
const
|
|
422
|
-
if (
|
|
423
|
-
const s = n.extractArtist(
|
|
420
|
+
if ("metadata" in r) {
|
|
421
|
+
const e = n.parseMetadata(r.metadata);
|
|
422
|
+
if (e) {
|
|
423
|
+
const s = n.extractArtist(e);
|
|
424
424
|
s && t.push(s);
|
|
425
425
|
}
|
|
426
426
|
}
|
|
427
427
|
}
|
|
428
428
|
return t;
|
|
429
429
|
}
|
|
430
|
-
function
|
|
430
|
+
function D(i) {
|
|
431
431
|
const t = /* @__PURE__ */ new Set();
|
|
432
|
-
for (const
|
|
433
|
-
if ("genre" in
|
|
434
|
-
t.add(
|
|
432
|
+
for (const r of i.tracks) {
|
|
433
|
+
if ("genre" in r && typeof r.genre == "string" && r.genre) {
|
|
434
|
+
t.add(r.genre);
|
|
435
435
|
continue;
|
|
436
436
|
}
|
|
437
|
-
if ("metadata" in
|
|
438
|
-
const
|
|
439
|
-
|
|
437
|
+
if ("metadata" in r) {
|
|
438
|
+
const e = n.parseMetadata(r.metadata);
|
|
439
|
+
e && typeof e.genre == "string" && e.genre && t.add(e.genre);
|
|
440
440
|
}
|
|
441
441
|
}
|
|
442
442
|
return Array.from(t).sort();
|
|
443
443
|
}
|
|
444
|
-
function
|
|
444
|
+
function I(i) {
|
|
445
445
|
const t = /* @__PURE__ */ new Set();
|
|
446
|
-
for (const
|
|
447
|
-
if ("tags" in
|
|
448
|
-
for (const
|
|
449
|
-
|
|
446
|
+
for (const r of i.tracks) {
|
|
447
|
+
if ("tags" in r && Array.isArray(r.tags)) {
|
|
448
|
+
for (const e of r.tags)
|
|
449
|
+
e && t.add(e.toLowerCase());
|
|
450
450
|
continue;
|
|
451
451
|
}
|
|
452
|
-
if ("metadata" in
|
|
453
|
-
const
|
|
454
|
-
if (
|
|
455
|
-
for (const s of
|
|
452
|
+
if ("metadata" in r) {
|
|
453
|
+
const e = n.parseMetadata(r.metadata);
|
|
454
|
+
if (e && Array.isArray(e.tags))
|
|
455
|
+
for (const s of e.tags)
|
|
456
456
|
s && t.add(String(s).toLowerCase());
|
|
457
457
|
}
|
|
458
458
|
}
|
|
459
459
|
return Array.from(t).sort();
|
|
460
460
|
}
|
|
461
|
-
function
|
|
461
|
+
function C(i) {
|
|
462
462
|
let t = 0;
|
|
463
|
-
for (const
|
|
464
|
-
if ("duration" in
|
|
465
|
-
t +=
|
|
463
|
+
for (const r of i.tracks) {
|
|
464
|
+
if ("duration" in r && typeof r.duration == "number") {
|
|
465
|
+
t += r.duration;
|
|
466
466
|
continue;
|
|
467
467
|
}
|
|
468
|
-
if ("metadata" in
|
|
469
|
-
const
|
|
470
|
-
|
|
468
|
+
if ("metadata" in r) {
|
|
469
|
+
const e = n.parseMetadata(r.metadata);
|
|
470
|
+
e && typeof e.duration == "number" && (t += e.duration);
|
|
471
471
|
}
|
|
472
472
|
}
|
|
473
473
|
return t;
|
|
474
474
|
}
|
|
475
|
-
function
|
|
475
|
+
function H(i) {
|
|
476
476
|
return i.tracks.length;
|
|
477
477
|
}
|
|
478
|
-
function
|
|
478
|
+
function P(i) {
|
|
479
479
|
const t = [];
|
|
480
|
-
for (const
|
|
481
|
-
const
|
|
482
|
-
let u = "", c = "";
|
|
483
|
-
if ("title" in
|
|
484
|
-
u =
|
|
485
|
-
else if ("metadata" in
|
|
486
|
-
const
|
|
487
|
-
|
|
480
|
+
for (const r of i.tracks) {
|
|
481
|
+
const e = _(r), s = g(r), a = y(r);
|
|
482
|
+
let u = "", c = "", f;
|
|
483
|
+
if ("title" in r)
|
|
484
|
+
u = r.title || "", c = r.artist || "", f = r.description || void 0;
|
|
485
|
+
else if ("metadata" in r) {
|
|
486
|
+
const o = n.parseMetadata(r.metadata);
|
|
487
|
+
o && (u = n.extractTitle(o) || "", c = n.extractArtist(o) || "", f = n.extractDescription(o) || void 0);
|
|
488
488
|
}
|
|
489
|
-
if (
|
|
490
|
-
const
|
|
489
|
+
if (e) {
|
|
490
|
+
const o = {
|
|
491
491
|
title: u,
|
|
492
492
|
artist: c,
|
|
493
|
-
audio_url:
|
|
493
|
+
audio_url: e,
|
|
494
494
|
image_url: s || ""
|
|
495
|
-
},
|
|
496
|
-
|
|
495
|
+
}, l = A(r);
|
|
496
|
+
l && l !== e && (o.audio_url_lossless = l), a && (o.image_thumb_url = a), f && (o.description = f), "audio_ipfs_hash" in r && typeof r.audio_ipfs_hash == "string" && (o.audio_ipfs_hash = r.audio_ipfs_hash), "artwork_ipfs_hash" in r && typeof r.artwork_ipfs_hash == "string" && (o.artwork_ipfs_hash = r.artwork_ipfs_hash), "mint_function" in r && typeof r.mint_function == "string" && (o.mint_function = r.mint_function), "mint_price" in r && typeof r.mint_price == "string" && (o.mint_price = r.mint_price), "mint_snapshot_time" in r && typeof r.mint_snapshot_time == "number" && (o.mint_snapshot_time = r.mint_snapshot_time), "mint_token" in r && typeof r.mint_token == "string" && (o.mint_token = r.mint_token), t.push(o);
|
|
497
497
|
}
|
|
498
498
|
}
|
|
499
499
|
return t;
|
|
500
500
|
}
|
|
501
|
-
function
|
|
501
|
+
function W(i) {
|
|
502
502
|
const t = [];
|
|
503
|
-
for (const
|
|
504
|
-
if ("audio_url" in
|
|
505
|
-
t.push({ ...
|
|
503
|
+
for (const r of i.tracks) {
|
|
504
|
+
if ("audio_url" in r) {
|
|
505
|
+
t.push({ ...r });
|
|
506
506
|
continue;
|
|
507
507
|
}
|
|
508
|
-
if ("metadata" in
|
|
509
|
-
const
|
|
510
|
-
if (
|
|
511
|
-
const s = n.extractAudioUrlLossless(
|
|
508
|
+
if ("metadata" in r) {
|
|
509
|
+
const e = n.parseMetadata(r.metadata);
|
|
510
|
+
if (e) {
|
|
511
|
+
const s = n.extractAudioUrlLossless(e), a = n.extractAudioUrl(e);
|
|
512
512
|
t.push({
|
|
513
|
-
id:
|
|
514
|
-
chain_name:
|
|
515
|
-
token_address:
|
|
516
|
-
token_id:
|
|
517
|
-
tx_id:
|
|
518
|
-
platform:
|
|
519
|
-
title: n.extractTitle(
|
|
520
|
-
artist: n.extractArtist(
|
|
521
|
-
audio_url:
|
|
522
|
-
image_url: n.extractImageUrl(
|
|
523
|
-
image_thumb_url: n.extractImageThumbUrl(
|
|
524
|
-
duration:
|
|
525
|
-
genre:
|
|
526
|
-
tags:
|
|
527
|
-
bpm:
|
|
528
|
-
key:
|
|
529
|
-
album:
|
|
530
|
-
description:
|
|
531
|
-
attributes: n.convertAttributes(
|
|
532
|
-
...s && s !==
|
|
533
|
-
// v0.4 IPFS hash
|
|
534
|
-
...
|
|
535
|
-
...
|
|
513
|
+
id: r.chain_name === "AR" ? `AR-${r.tx_id}` : `${r.chain_name}-${r.token_address}-${r.token_id}`,
|
|
514
|
+
chain_name: r.chain_name,
|
|
515
|
+
token_address: r.token_address,
|
|
516
|
+
token_id: r.token_id,
|
|
517
|
+
tx_id: r.tx_id,
|
|
518
|
+
platform: r.platform,
|
|
519
|
+
title: n.extractTitle(e),
|
|
520
|
+
artist: n.extractArtist(e),
|
|
521
|
+
audio_url: a,
|
|
522
|
+
image_url: n.extractImageUrl(e),
|
|
523
|
+
image_thumb_url: n.extractImageThumbUrl(e),
|
|
524
|
+
duration: e.duration,
|
|
525
|
+
genre: e.genre,
|
|
526
|
+
tags: e.tags,
|
|
527
|
+
bpm: e.bpm,
|
|
528
|
+
key: e.key,
|
|
529
|
+
album: e.album,
|
|
530
|
+
description: n.extractDescription(e),
|
|
531
|
+
attributes: n.convertAttributes(e.attributes),
|
|
532
|
+
...s && s !== a ? { audio_url_lossless: s } : {},
|
|
533
|
+
// v0.4 IPFS hash + mint fields from the raw track wrapper
|
|
534
|
+
...r.audio_ipfs_hash ? { audio_ipfs_hash: r.audio_ipfs_hash } : {},
|
|
535
|
+
...r.artwork_ipfs_hash ? { artwork_ipfs_hash: r.artwork_ipfs_hash } : {},
|
|
536
|
+
...r.mint_function ? { mint_function: r.mint_function } : {},
|
|
537
|
+
...r.mint_price ? { mint_price: r.mint_price } : {},
|
|
538
|
+
...r.mint_snapshot_time ? { mint_snapshot_time: r.mint_snapshot_time } : {},
|
|
539
|
+
...r.mint_token ? { mint_token: r.mint_token } : {}
|
|
536
540
|
});
|
|
537
541
|
}
|
|
538
542
|
}
|
|
539
543
|
}
|
|
540
544
|
return t;
|
|
541
545
|
}
|
|
542
|
-
function
|
|
546
|
+
function E(i) {
|
|
543
547
|
const t = [];
|
|
544
|
-
for (const
|
|
545
|
-
const
|
|
546
|
-
|
|
548
|
+
for (const r of i.tracks) {
|
|
549
|
+
const e = h(r);
|
|
550
|
+
e && t.push(e);
|
|
547
551
|
}
|
|
548
552
|
return t;
|
|
549
553
|
}
|
|
550
|
-
function
|
|
554
|
+
function N(i) {
|
|
551
555
|
const t = [];
|
|
552
|
-
for (const
|
|
553
|
-
const
|
|
554
|
-
if (!
|
|
555
|
-
const s =
|
|
556
|
-
let c = "",
|
|
557
|
-
if ("title" in
|
|
558
|
-
c =
|
|
559
|
-
else if ("metadata" in
|
|
560
|
-
const
|
|
561
|
-
|
|
556
|
+
for (const r of i.tracks) {
|
|
557
|
+
const e = h(r);
|
|
558
|
+
if (!e) continue;
|
|
559
|
+
const s = _(r), a = g(r), u = y(r);
|
|
560
|
+
let c = "", f = "", o;
|
|
561
|
+
if ("title" in r)
|
|
562
|
+
c = r.title || "", f = r.artist || "", o = r.description || void 0;
|
|
563
|
+
else if ("metadata" in r) {
|
|
564
|
+
const p = n.parseMetadata(r.metadata);
|
|
565
|
+
p && (c = n.extractTitle(p) || "", f = n.extractArtist(p) || "", o = n.extractDescription(p) || void 0);
|
|
562
566
|
}
|
|
563
|
-
const
|
|
567
|
+
const l = {
|
|
564
568
|
title: c,
|
|
565
|
-
artist:
|
|
569
|
+
artist: f,
|
|
566
570
|
audio_url: s || "",
|
|
567
|
-
image_url:
|
|
568
|
-
vrm:
|
|
571
|
+
image_url: a || "",
|
|
572
|
+
vrm: e
|
|
569
573
|
};
|
|
570
|
-
u && (
|
|
574
|
+
u && (l.image_thumb_url = u), o && (l.description = o), t.push(l);
|
|
571
575
|
}
|
|
572
576
|
return t;
|
|
573
577
|
}
|
|
574
|
-
const
|
|
578
|
+
const d = [
|
|
575
579
|
"ipfs.io",
|
|
576
580
|
"cloudflare-ipfs.com",
|
|
577
581
|
"dweb.link",
|
|
@@ -585,78 +589,93 @@ const y = [
|
|
|
585
589
|
"spinamp.mypinata.cloud",
|
|
586
590
|
"catalogworks.b-cdn.net",
|
|
587
591
|
"www.heds.cloud"
|
|
588
|
-
],
|
|
592
|
+
], k = "ipfs.io", m = "/ipfs/", w = /^Qm[1-9A-HJ-NP-Za-km-z]{44}$/, x = /^b[a-z2-7]{55,}$/;
|
|
593
|
+
function v(i) {
|
|
594
|
+
return w.test(i) || x.test(i);
|
|
595
|
+
}
|
|
596
|
+
const T = /^ipfs_[a-z]+$/;
|
|
589
597
|
function b(i) {
|
|
598
|
+
const t = i.split("/").filter(Boolean);
|
|
599
|
+
for (let r = 0; r < t.length - 1; r++)
|
|
600
|
+
if (T.test(t[r]) && v(t[r + 1])) {
|
|
601
|
+
const e = t[r + 1], s = t.slice(r + 2);
|
|
602
|
+
return s.length > 0 ? `${e}/${s.join("/")}` : e;
|
|
603
|
+
}
|
|
604
|
+
return null;
|
|
605
|
+
}
|
|
606
|
+
function U(i) {
|
|
590
607
|
if (!i || typeof i != "string") return null;
|
|
591
608
|
if (i.startsWith("ipfs://ipfs/"))
|
|
592
609
|
return i.slice(12);
|
|
593
610
|
if (i.startsWith("ipfs://"))
|
|
594
611
|
return i.slice(7);
|
|
595
612
|
try {
|
|
596
|
-
const t = new URL(i), { hostname:
|
|
613
|
+
const t = new URL(i), { hostname: r, pathname: e } = t, s = r.match(/^([A-Za-z0-9]+)\.ipfs\.dweb\.link$/);
|
|
597
614
|
if (s)
|
|
598
|
-
return `${s[1]}${
|
|
599
|
-
if (
|
|
600
|
-
(
|
|
601
|
-
) &&
|
|
602
|
-
return
|
|
615
|
+
return `${s[1]}${e}`;
|
|
616
|
+
if (d.some(
|
|
617
|
+
(c) => r === c || r.endsWith("." + c)
|
|
618
|
+
) && e.startsWith(m))
|
|
619
|
+
return e.slice(m.length);
|
|
620
|
+
const u = b(e);
|
|
621
|
+
if (u) return u;
|
|
603
622
|
} catch {
|
|
604
623
|
}
|
|
605
624
|
return null;
|
|
606
625
|
}
|
|
607
|
-
function
|
|
626
|
+
function R(i) {
|
|
608
627
|
if (!i || typeof i != "string") return !1;
|
|
609
628
|
if (i.startsWith("ipfs://")) return !0;
|
|
610
629
|
try {
|
|
611
|
-
const t = new URL(i), { hostname:
|
|
612
|
-
if (/^[A-Za-z0-9]+\.ipfs\.dweb\.link$/.test(
|
|
613
|
-
(
|
|
614
|
-
) &&
|
|
630
|
+
const t = new URL(i), { hostname: r, pathname: e } = t;
|
|
631
|
+
if (/^[A-Za-z0-9]+\.ipfs\.dweb\.link$/.test(r) || d.some(
|
|
632
|
+
(a) => r === a || r.endsWith("." + a)
|
|
633
|
+
) && e.startsWith(m) || b(e)) return !0;
|
|
615
634
|
} catch {
|
|
616
635
|
}
|
|
617
636
|
return !1;
|
|
618
637
|
}
|
|
619
|
-
function
|
|
638
|
+
function S(i) {
|
|
620
639
|
if (!(!i || i.startsWith("ipfs://")))
|
|
621
640
|
try {
|
|
622
641
|
const { hostname: t } = new URL(i);
|
|
623
|
-
return
|
|
624
|
-
(
|
|
642
|
+
return d.some(
|
|
643
|
+
(e) => t === e || t.endsWith("." + e)
|
|
625
644
|
) ? t : void 0;
|
|
626
645
|
} catch {
|
|
627
646
|
return;
|
|
628
647
|
}
|
|
629
648
|
}
|
|
630
|
-
function
|
|
649
|
+
function G(i, t = {}) {
|
|
631
650
|
if (!i) return i;
|
|
632
|
-
const
|
|
633
|
-
if (
|
|
651
|
+
const r = typeof t == "string" ? { gatewayHost: t } : t, { gatewayHost: e = k, preserveOriginalGateway: s = !1 } = r, a = U(i);
|
|
652
|
+
if (a) {
|
|
634
653
|
if (s) {
|
|
635
|
-
const u =
|
|
654
|
+
const u = S(i);
|
|
636
655
|
if (u)
|
|
637
|
-
return `https://${u}/ipfs/${
|
|
656
|
+
return `https://${u}/ipfs/${a}`;
|
|
638
657
|
}
|
|
639
|
-
return `https://${
|
|
658
|
+
return `https://${e}/ipfs/${a}`;
|
|
640
659
|
}
|
|
641
660
|
return i;
|
|
642
661
|
}
|
|
643
662
|
export {
|
|
644
|
-
|
|
645
|
-
|
|
663
|
+
k as D,
|
|
664
|
+
d as K,
|
|
646
665
|
n as M,
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
666
|
+
M as a,
|
|
667
|
+
W as b,
|
|
668
|
+
D as c,
|
|
669
|
+
j as d,
|
|
670
|
+
U as e,
|
|
671
|
+
I as f,
|
|
672
|
+
$ as g,
|
|
673
|
+
C as h,
|
|
674
|
+
H as i,
|
|
675
|
+
F as j,
|
|
676
|
+
P as k,
|
|
677
|
+
N as l,
|
|
678
|
+
E as m,
|
|
679
|
+
R as n,
|
|
680
|
+
G as r
|
|
662
681
|
};
|