spotify-ts-wrapper
Version:
Spotify TypeScript wrapper.
31 lines (30 loc) • 1.82 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.parsePodcast = parsePodcast;
const getSpotifyId_1 = require("../Utils/getSpotifyId");
function parsePodcast(body) {
var _a, _b, _c, _d, _e, _f, _g, _h;
const { data } = body;
const podcast = data === null || data === void 0 ? void 0 : data.podcastUnionV2;
const name = podcast === null || podcast === void 0 ? void 0 : podcast.name;
const image = (_c = (_b = (_a = podcast === null || podcast === void 0 ? void 0 : podcast.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 publisher = (_d = podcast === null || podcast === void 0 ? void 0 : podcast.publisher) === null || _d === void 0 ? void 0 : _d.name;
const description = podcast === null || podcast === void 0 ? void 0 : podcast.description;
const type = podcast === null || podcast === void 0 ? void 0 : podcast.__typename;
const id = podcast === null || podcast === void 0 ? void 0 : podcast.id;
const rating = (_f = (_e = podcast === null || podcast === void 0 ? void 0 : podcast.rating) === null || _e === void 0 ? void 0 : _e.averageRating) === null || _f === void 0 ? void 0 : _f.average;
const topics = (_h = (_g = podcast === null || podcast === void 0 ? void 0 : podcast.topics) === null || _g === void 0 ? void 0 : _g.items) === null || _h === void 0 ? void 0 : _h.map((item) => ({
name: item === null || item === void 0 ? void 0 : item.title,
id: (0, getSpotifyId_1.extractSpotifyID)(item === null || item === void 0 ? void 0 : item.uri),
}));
return {
name,
image,
publisher,
description,
type,
id,
rating,
topics,
};
}