UNPKG

spotify-ts-wrapper

Version:

Spotify TypeScript wrapper.

39 lines (38 loc) 2.1 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.parsePodcastShow = parsePodcastShow; function parsePodcastShow(body) { var _a, _b; const { data } = body; const podcast = data === null || data === void 0 ? void 0 : data.podcastUnionV2; const type = podcast === null || podcast === void 0 ? void 0 : podcast.__typename; const name = podcast === null || podcast === void 0 ? void 0 : podcast.name; const id = podcast === null || podcast === void 0 ? void 0 : podcast.id; const episodes = (_b = (_a = podcast === null || podcast === void 0 ? void 0 : podcast.episodesV2) === null || _a === void 0 ? void 0 : _a.items) === null || _b === void 0 ? void 0 : _b.map((item) => { var _a, _b, _c, _d, _e; const entity = item === null || item === void 0 ? void 0 : item.entity; const content = entity === null || entity === void 0 ? void 0 : entity.data; const title = content === null || content === void 0 ? void 0 : content.name; const type = content === null || content === void 0 ? void 0 : content.__typename; const description = content === null || content === void 0 ? void 0 : content.description; const image = (_c = (_b = (_a = content === null || content === void 0 ? void 0 : content.coverArt) === null || _a === void 0 ? void 0 : _a.sources) === null || _b === void 0 ? void 0 : _b.at(-1)) === null || _c === void 0 ? void 0 : _c.url; const id = content === null || content === void 0 ? void 0 : content.id; const contentRating = (_d = content === null || content === void 0 ? void 0 : content.contentRating) === null || _d === void 0 ? void 0 : _d.label; const date = (_e = content === null || content === void 0 ? void 0 : content.releaseDate) === null || _e === void 0 ? void 0 : _e.isoString; return { title, type, id, description, image, contentRating, date, }; }); return { id, name, type, episodes, }; }