playlist-data-engine 1.7.2 → 1.7.3

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.
@@ -3,6 +3,7 @@
3
3
  * "No nonsense" functions that return arrays of basic data from playlists
4
4
  */
5
5
  import type { ServerlessPlaylist, RawArweavePlaylist } from '../core/types/Playlist.js';
6
+ import { type MixInfo } from '../core/parser/TrackExtras.js';
6
7
  /** Input type that accepts both parsed and raw playlists */
7
8
  export type PlaylistInput = ServerlessPlaylist | RawArweavePlaylist;
8
9
  /** Simplified track object for getTracks() */
@@ -20,6 +21,22 @@ export interface SimpleTrack {
20
21
  mint_price?: string;
21
22
  mint_snapshot_time?: number;
22
23
  mint_token?: string;
24
+ /** Name of the entry's pinned mix (absent when the entry plays primary audio) */
25
+ selected_mix?: string;
26
+ }
27
+ /** Track object with mix data for getMixTracks() */
28
+ export interface MixTrackInfo {
29
+ title: string;
30
+ artist: string;
31
+ description?: string;
32
+ /** The entry's audio URL, already repointed when the entry pins a mix */
33
+ audio_url: string;
34
+ audio_url_lossless?: string;
35
+ image_url: string;
36
+ /** Name of the entry's pinned mix (absent when the entry plays primary audio) */
37
+ selected_mix?: string;
38
+ /** All mixes the track ships */
39
+ mixes: MixInfo[];
23
40
  }
24
41
  /** Track object with VRM data for getVRMTracks() */
25
42
  export interface VRMTrack {
@@ -154,4 +171,24 @@ export declare function getVRMs(playlist: PlaylistInput): string[];
154
171
  * // [{ title: 'Song', artist: 'Artist', audio_url: '...', image_url: '...', image_thumb_url: '...', vrm: '...' }, ...]
155
172
  */
156
173
  export declare function getVRMTracks(playlist: PlaylistInput): VRMTrack[];
174
+ /**
175
+ * Get all alternate mixes across a playlist's tracks
176
+ * @param playlist - Parsed or raw playlist
177
+ * @returns Array of mixes (flattened across tracks, in track order)
178
+ *
179
+ * @example
180
+ * const mixes = getMixes(playlist);
181
+ * // [{ name: 'Instrumental', uri: '...', mime_type: 'audio/mpeg', conditions: [] }, ...]
182
+ */
183
+ export declare function getMixes(playlist: PlaylistInput): MixInfo[];
184
+ /**
185
+ * Get tracks that ship alternate mixes, with each entry's pin resolved
186
+ * @param playlist - Parsed or raw playlist
187
+ * @returns Array of track objects with their mixes and pinned mix name
188
+ *
189
+ * @example
190
+ * const mixTracks = getMixTracks(playlist);
191
+ * // [{ title: 'Song', artist: 'Artist', audio_url: '...', selected_mix: 'Instrumental', mixes: [...] }, ...]
192
+ */
193
+ export declare function getMixTracks(playlist: PlaylistInput): MixTrackInfo[];
157
194
  //# sourceMappingURL=playlistUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"playlistUtils.d.ts","sourceRoot":"","sources":["../../src/utils/playlistUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAiB,MAAM,2BAA2B,CAAC;AAOvG,4DAA4D;AAC5D,MAAM,MAAM,aAAa,GAAG,kBAAkB,GAAG,kBAAkB,CAAC;AAEpE,8CAA8C;AAC9C,MAAM,WAAW,WAAW;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,oDAAoD;AACpD,MAAM,WAAW,QAAQ;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EA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,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAmErF;AAMD;;;;;;;;;GASG;AACH,wBAAgB,OAAO,CAAC,QAAQ,EAAE,aAAa,GAAG,MAAM,EAAE,CAWzD;AAED;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,aAAa,GAAG,QAAQ,EAAE,CAqDhE;AAMD;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,aAAa,GAAG,OAAO,EAAE,CAQ3D;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,aAAa,GAAG,YAAY,EAAE,CA0DpE"}
@@ -186,4 +186,31 @@ export declare const CharacterSheetSchema: z.ZodObject<{
186
186
  seed: z.ZodString;
187
187
  generated_at: z.ZodString;
188
188
  }, z.core.$strip>;
189
+ /**
190
+ * Mix condition schema (alternate mixes)
191
+ */
192
+ export declare const MixConditionSchema: z.ZodObject<{
193
+ type: z.ZodString;
194
+ value: z.ZodString;
195
+ }, z.core.$strip>;
196
+ /**
197
+ * Alternate mix schema
198
+ */
199
+ export declare const MixInfoSchema: z.ZodObject<{
200
+ name: z.ZodString;
201
+ uri: z.ZodOptional<z.ZodString>;
202
+ mime_type: z.ZodOptional<z.ZodString>;
203
+ conditions: z.ZodArray<z.ZodObject<{
204
+ type: z.ZodString;
205
+ value: z.ZodString;
206
+ }, z.core.$strip>>;
207
+ }, z.core.$strip>;
208
+ /**
209
+ * Stem schema
210
+ */
211
+ export declare const StemInfoSchema: z.ZodObject<{
212
+ name: z.ZodString;
213
+ uri: z.ZodOptional<z.ZodString>;
214
+ mime_type: z.ZodOptional<z.ZodString>;
215
+ }, z.core.$strip>;
189
216
  //# sourceMappingURL=validators.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../../src/utils/validators.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MA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zB,CAAC"}
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/jasondesante/playlist-data-engine.git"
8
8
  },
9
- "version": "1.7.2",
9
+ "version": "1.7.3",
10
10
  "type": "module",
11
11
  "main": "./dist/playlist-data-engine.js",
12
12
  "module": "./dist/playlist-data-engine.mjs",
@@ -1 +0,0 @@
1
- "use strict";require("./arweaveGatewayManager-C9SIMDTd.cjs");class n{static extractAudioUrl(t){const r=["mp3_url","mp3Url","lossy_audio","lossyAudio","audio_url","audioUrl","audio","lossless_audio","losslessAudio","animation_url","animationUrl","multimedia_url","multimediaUrl"];for(const e of r)if(t[e]&&typeof t[e]=="string")return t[e];return null}static extractAudioUrlLossless(t){const r=["lossless_audio","losslessAudio","wav_url","wavUrl","flac_url","flacUrl","audio_url","audioUrl"];for(const e of r)if(t[e]&&typeof t[e]=="string")return t[e];return null}static extractImageUrl(t){const r=["image_small","imageSmall","image","image_large","imageLarge","image_thumb","imageThumb","image_url","imageUrl","image_uri","imageUri","image_preview","imagePreview"];for(const s of r)if(t[s]&&typeof t[s]=="string")return t[s];const e=[this.extractNestedUri(t,"artwork","uri"),this.extractNestedUri(t,"project","artwork","uri"),this.extractNestedUri(t,"primaryMedia","uri")];for(const s of e)if(s)return s;return null}static extractImageThumbUrl(t){return t.image_thumb_url&&typeof t.image_thumb_url=="string"?t.image_thumb_url:t.image_thumb&&typeof t.image_thumb=="string"?t.image_thumb:null}static extractTitle(t){return t.name&&typeof t.name=="string"?t.name:t.title&&typeof t.title=="string"?t.title:null}static extractArtist(t){const r=["artist","artist_name","artistName","album_artist","albumArtist","created_by","createdBy","minter"];for(const e of r)if(t[e]&&typeof t[e]=="string")return t[e];if(Array.isArray(t.attributes)){const e=t.attributes.find(s=>s.trait_type?.toLowerCase()==="artist"&&s.value!==void 0);if(e&&typeof e.value=="string")return e.value}return null}static parseMetadata(t){if(!t)return null;if(typeof t=="object"&&!Array.isArray(t))return t;if(typeof t=="string")try{const r=JSON.parse(t);if(typeof r=="object"&&!Array.isArray(r))return r}catch(r){return console.warn("Failed to parse metadata:",r),null}return null}static extractGenre(t){if(typeof t.genre=="string")return t.genre;if(Array.isArray(t.genre)&&t.genre.length>0){const e=t.genre[0];return typeof e=="string"?e:""}if(Array.isArray(t.attributes)){const e=t.attributes.find(s=>s.trait_type?.toLowerCase()==="genre"&&s.value!==void 0);if(e){if(typeof e.value=="string")return e.value;if(Array.isArray(e.value)&&e.value.length>0){const s=e.value[0];return typeof s=="string"?s:""}}}if(t.attributes&&typeof t.attributes=="object"&&!Array.isArray(t.attributes)){const e=t.attributes;for(const s of Object.keys(e))if(s.toLowerCase()==="genre"&&typeof e[s]=="string")return e[s]}const r=t["attribute "];if(r&&typeof r=="object"&&!Array.isArray(r)){const e=r.genre;if(typeof e=="string")return e}return""}static extractTags(t){const r=[];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)){const e=t.properties.tags;Array.isArray(e)?r.push(...e):typeof e=="string"&&r.push(...e.split(","))}if(Array.isArray(t.attributes))for(const e of t.attributes){if(!e||typeof e!="object")continue;const s=e.trait_type;if(typeof s=="string"&&s.toLowerCase().match(/^tags?$/)){const a=e.value;Array.isArray(a)?r.push(...a):typeof a=="string"&&r.push(...a.split(","))}}else if(t.attributes&&typeof t.attributes=="object"){const e=t.attributes;for(const s of Object.keys(e))if(s.toLowerCase().match(/^tags?$/)){const a=e[s];Array.isArray(a)?r.push(...a):typeof a=="string"&&r.push(...a.split(","))}}return n.normalizeTags(r)}static extractDescription(t){const r=["description","track_description","trackDescription","description_text","descriptionText","desc","blurb"];for(const e of r)if(t[e]&&typeof t[e]=="string")return t[e];if(Array.isArray(t.attributes)){const e=t.attributes.find(s=>s.trait_type?.toLowerCase()==="description"&&typeof s.value=="string");if(e&&typeof e.value=="string")return e.value}return n.deepFindString(t,/description/i)}static extractAlbumDescription(t){const r=["album_description","albumDescription"];for(const s of r)if(t[s]&&typeof t[s]=="string")return t[s];const e=t.album;return e&&typeof e=="object"&&!Array.isArray(e)?n.deepFindString(e,/description|liner|notes/i):null}static extractArtistDescription(t){const r=["artist_description","artistDescription","artist_bio","artistBio"];for(const s of r)if(t[s]&&typeof t[s]=="string")return t[s];const e=t.artist;return e&&typeof e=="object"&&!Array.isArray(e)?n.deepFindString(e,/description|bio|about/i):null}static deepFindString(t,r,e=5){const s=new Set,a=[{node:t,depth:0}];for(;a.length>0;){const{node:u,depth:c}=a.shift();for(const f of Object.keys(u)){const o=u[f];if(typeof o=="string"&&o&&r.test(f))return o}if(!(c>=e))for(const f of Object.keys(u)){const o=u[f];o&&typeof o=="object"&&!Array.isArray(o)&&!s.has(o)&&(s.add(o),a.push({node:o,depth:c+1}))}}return null}static normalizeTags(t){const r=new Set;for(const e of t){if(e==null)continue;const s=String(e).trim().toLowerCase();s&&r.add(s)}return Array.from(r)}static convertAttributes(t){if(!Array.isArray(t))return null;const r={};for(const e of t)e.trait_type&&e.value!==void 0&&(r[e.trait_type]=e.value);return Object.keys(r).length>0?r:null}static extractNestedUri(t,...r){let e=t;for(const s of r)if(e&&typeof e=="object"&&!Array.isArray(e))e=e[s];else return null;return typeof e=="string"?e:null}}function _(i){if("audio_url"in i&&typeof i.audio_url=="string")return i.audio_url;if("metadata"in i){const t=n.parseMetadata(i.metadata);if(t)return n.extractAudioUrl(t)}return null}function w(i){if("audio_url_lossless"in i&&typeof i.audio_url_lossless=="string")return i.audio_url_lossless;if("metadata"in i){const t=n.parseMetadata(i.metadata);if(t)return n.extractAudioUrlLossless(t)}return null}function d(i){if("image_url"in i&&typeof i.image_url=="string")return i.image_url;if("metadata"in i){if("artwork_url"in i&&typeof i.artwork_url=="string")return i.artwork_url;const t=n.parseMetadata(i.metadata);if(t)return n.extractImageUrl(t)}return null}function y(i){if("image_thumb_url"in i&&typeof i.image_thumb_url=="string")return i.image_thumb_url;if("metadata"in i){const t=n.parseMetadata(i.metadata);if(t)return n.extractImageThumbUrl(t)}return null}function h(i){if("metadata"in i){const t=n.parseMetadata(i.metadata);if(t&&typeof t.vrm=="string"&&t.vrm)return t.vrm}return"extras"in i&&i.extras&&typeof i.extras.vrm=="string"&&i.extras.vrm||null}function x(i){const t=[];for(const r of i.tracks){const e=_(r);e&&t.push(e)}return t}function T(i){const t=[];for(const r of i.tracks){const e=d(r);e&&t.push(e)}return t}function v(i){const t=[];for(const r of i.tracks){if("title"in r&&typeof r.title=="string"){t.push(r.title);continue}if("metadata"in r){const e=n.parseMetadata(r.metadata);if(e){const s=n.extractTitle(e);s&&t.push(s)}}}return t}function U(i){const t=[];for(const r of i.tracks){if("artist"in r&&typeof r.artist=="string"){t.push(r.artist);continue}if("metadata"in r){const e=n.parseMetadata(r.metadata);if(e){const s=n.extractArtist(e);s&&t.push(s)}}}return t}function S(i){const t=new Set;for(const r of i.tracks){if("genre"in r&&typeof r.genre=="string"&&r.genre){t.add(r.genre);continue}if("metadata"in r){const e=n.parseMetadata(r.metadata);e&&typeof e.genre=="string"&&e.genre&&t.add(e.genre)}}return Array.from(t).sort()}function F(i){const t=new Set;for(const r of i.tracks){if("tags"in r&&Array.isArray(r.tags)){for(const e of r.tags)e&&t.add(e.toLowerCase());continue}if("metadata"in r){const e=n.parseMetadata(r.metadata);if(e&&Array.isArray(e.tags))for(const s of e.tags)s&&t.add(String(s).toLowerCase())}}return Array.from(t).sort()}function I(i){let t=0;for(const r of i.tracks){if("duration"in r&&typeof r.duration=="number"){t+=r.duration;continue}if("metadata"in r){const e=n.parseMetadata(r.metadata);e&&typeof e.duration=="number"&&(t+=e.duration)}}return t}function L(i){return i.tracks.length}function M(i){const t=[];for(const r of i.tracks){const e=_(r),s=d(r),a=y(r);let u="",c="",f;if("title"in r)u=r.title||"",c=r.artist||"",f=r.description||void 0;else if("metadata"in r){const o=n.parseMetadata(r.metadata);o&&(u=n.extractTitle(o)||"",c=n.extractArtist(o)||"",f=n.extractDescription(o)||void 0)}if(e){const o={title:u,artist:c,audio_url:e,image_url:s||""},l=w(r);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)}}return t}function D(i){const t=[];for(const r of i.tracks){if("audio_url"in r){t.push({...r});continue}if("metadata"in r){const e=n.parseMetadata(r.metadata);if(e){const s=n.extractAudioUrlLossless(e),a=n.extractAudioUrl(e);t.push({id:r.chain_name==="AR"?`AR-${r.tx_id}`:`${r.chain_name}-${r.token_address}-${r.token_id}`,chain_name:r.chain_name,token_address:r.token_address,token_id:r.token_id,tx_id:r.tx_id,platform:r.platform,title:n.extractTitle(e),artist:n.extractArtist(e),audio_url:a,image_url:n.extractImageUrl(e),image_thumb_url:n.extractImageThumbUrl(e),duration:e.duration,genre:e.genre,tags:e.tags,bpm:e.bpm,key:e.key,album:e.album,description:n.extractDescription(e),attributes:n.convertAttributes(e.attributes),...s&&s!==a?{audio_url_lossless:s}:{},...r.audio_ipfs_hash?{audio_ipfs_hash:r.audio_ipfs_hash}:{},...r.artwork_ipfs_hash?{artwork_ipfs_hash:r.artwork_ipfs_hash}:{},...r.mint_function?{mint_function:r.mint_function}:{},...r.mint_price?{mint_price:r.mint_price}:{},...r.mint_snapshot_time?{mint_snapshot_time:r.mint_snapshot_time}:{},...r.mint_token?{mint_token:r.mint_token}:{}})}}}return t}function P(i){const t=[];for(const r of i.tracks){const e=h(r);e&&t.push(e)}return t}function $(i){const t=[];for(const r of i.tracks){const e=h(r);if(!e)continue;const s=_(r),a=d(r),u=y(r);let c="",f="",o;if("title"in r)c=r.title||"",f=r.artist||"",o=r.description||void 0;else if("metadata"in r){const p=n.parseMetadata(r.metadata);p&&(c=n.extractTitle(p)||"",f=n.extractArtist(p)||"",o=n.extractDescription(p)||void 0)}const l={title:c,artist:f,audio_url:s||"",image_url:a||"",vrm:e};u&&(l.image_thumb_url=u),o&&(l.description=o),t.push(l)}return t}const m=["ipfs.io","cloudflare-ipfs.com","dweb.link","gateway.pinata.cloud","ipfs.infura.io","nftstorage.link","web3-music-pipeline.mypinata.cloud","soundxyz.mypinata.cloud","gold-broad-gibbon-29.mypinata.cloud","bonfire.mypinata.cloud","spinamp.mypinata.cloud","catalogworks.b-cdn.net","www.heds.cloud"],A="ipfs.io",g="/ipfs/",j=/^Qm[1-9A-HJ-NP-Za-km-z]{44}$/,C=/^b[a-z2-7]{55,}$/;function E(i){return j.test(i)||C.test(i)}const W=/^ipfs_[a-z]+$/;function b(i){const t=i.split("/").filter(Boolean);for(let r=0;r<t.length-1;r++)if(W.test(t[r])&&E(t[r+1])){const e=t[r+1],s=t.slice(r+2);return s.length>0?`${e}/${s.join("/")}`:e}return null}function k(i){if(!i||typeof i!="string")return null;if(i.startsWith("ipfs://ipfs/"))return i.slice(12);if(i.startsWith("ipfs://"))return i.slice(7);try{const t=new URL(i),{hostname:r,pathname:e}=t,s=r.match(/^([A-Za-z0-9]+)\.ipfs\.dweb\.link$/);if(s)return`${s[1]}${e}`;if(m.some(c=>r===c||r.endsWith("."+c))&&e.startsWith(g))return e.slice(g.length);const u=b(e);if(u)return u}catch{}return null}function H(i){if(!i||typeof i!="string")return!1;if(i.startsWith("ipfs://"))return!0;try{const t=new URL(i),{hostname:r,pathname:e}=t;if(/^[A-Za-z0-9]+\.ipfs\.dweb\.link$/.test(r)||m.some(a=>r===a||r.endsWith("."+a))&&e.startsWith(g)||b(e))return!0}catch{}return!1}function N(i){if(!(!i||i.startsWith("ipfs://")))try{const{hostname:t}=new URL(i);return m.some(e=>t===e||t.endsWith("."+e))?t:void 0}catch{return}}function R(i,t={}){if(!i)return i;const r=typeof t=="string"?{gatewayHost:t}:t,{gatewayHost:e=A,preserveOriginalGateway:s=!1}=r,a=k(i);if(a){if(s){const u=N(i);if(u)return`https://${u}/ipfs/${a}`}return`https://${e}/ipfs/${a}`}return i}exports.DEFAULT_IPFS_GATEWAY=A;exports.KNOWN_IPFS_GATEWAY_HOSTS=m;exports.MetadataExtractor=n;exports.extractIPFSPath=k;exports.getArtists=U;exports.getAudioUrls=x;exports.getFullTracks=D;exports.getGenres=S;exports.getImageUrls=T;exports.getTags=F;exports.getTotalDuration=I;exports.getTrackCount=L;exports.getTrackTitles=v;exports.getTracks=M;exports.getVRMTracks=$;exports.getVRMs=P;exports.isIPFS=H;exports.resolveIPFSLink=R;