UNPKG

lunify.js

Version:

A basic api wrapper for the spotify api covering the oauth routes.

78 lines 2.24 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PlaylistTrack = exports.Track = exports.PartialTrack = void 0; const album_1 = require("../album"); const artist_1 = require("../artist"); class PartialTrack { client; album; artists; markets; disc; duration; explicit; externalUrls; url; id; playable; linkedFrom; restrictions; name; previewUrl; track; type; uri; local; constructor(client, data) { this.client = client; if (data.album) this.album = new album_1.PartialAlbum(client, data.album); this.artists = []; for (const artist of data.artists) this.artists.push(new artist_1.PartialArtist(client, artist)); this.markets = data.available_markets; this.disc = data.disc_number; this.duration = data.duration_ms; this.explicit = data.explicit; this.externalUrls = data.external_urls; this.url = data.href; this.id = data.id; this.playable = data.is_playable; this.linkedFrom = data.linked_from || {}; this.restrictions = data.restrictions?.reason || null; this.name = data.name; this.previewUrl = data.preview_url; this.track = data.track_number; this.type = data.type; this.uri = data.uri; this.local = data.is_local; } } exports.PartialTrack = PartialTrack; class Track extends PartialTrack { client; externalIds; popularity; constructor(client, data) { super(client, data); this.client = client; this.externalIds = data.external_ids; this.popularity = data.popularity; } } exports.Track = Track; class PlaylistTrack extends Track { client; // Will only be `null` in very old playlists. addedTimestamp; // Will only be `null` in very old playlists. addedBy; constructor(client, data) { super(client, data.track); this.client = client; this.addedTimestamp = data.added_at ? new Date(data.added_at).getTime() : null; this.addedBy = data.added_by; } } exports.PlaylistTrack = PlaylistTrack; //# sourceMappingURL=index.js.map