spotify-ts-wrapper
Version:
Spotify TypeScript wrapper.
28 lines (27 loc) • 1.85 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.recommendationsParser = recommendationsParser;
function recommendationsParser(body) {
var _a;
return (_a = body === null || body === void 0 ? void 0 : body.tracks) === null || _a === void 0 ? void 0 : _a.map((item) => {
var _a, _b, _c, _d, _e, _f, _g, _h;
const track = item;
return {
title: track === null || track === void 0 ? void 0 : track.name,
id: track === null || track === void 0 ? void 0 : track.id,
duration: track === null || track === void 0 ? void 0 : track.duration_ms,
artists: (_a = track === null || track === void 0 ? void 0 : track.artists) === null || _a === void 0 ? void 0 : _a.map((a) => ({
name: a === null || a === void 0 ? void 0 : a.name,
id: a === null || a === void 0 ? void 0 : a.id,
type: a === null || a === void 0 ? void 0 : a.type,
})),
album: {
title: (_b = track === null || track === void 0 ? void 0 : track.album) === null || _b === void 0 ? void 0 : _b.name,
date: (_d = new Date((_c = track === null || track === void 0 ? void 0 : track.album) === null || _c === void 0 ? void 0 : _c.release_date)) === null || _d === void 0 ? void 0 : _d.getFullYear(),
artwork: (_f = (_e = track === null || track === void 0 ? void 0 : track.album) === null || _e === void 0 ? void 0 : _e.images[0]) === null || _f === void 0 ? void 0 : _f.url,
type: (_g = track === null || track === void 0 ? void 0 : track.album) === null || _g === void 0 ? void 0 : _g.type,
id: (_h = track === null || track === void 0 ? void 0 : track.album) === null || _h === void 0 ? void 0 : _h.id,
},
};
});
}