UNPKG

bandcamp-fetch

Version:
68 lines 2.44 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const FanItemsBaseParser_js_1 = __importDefault(require("./FanItemsBaseParser.js")); class FanFollowingParser extends FanItemsBaseParser_js_1.default { static parseFollowingBandsFromPage(html, opts) { return this.parsePageItems(html, { ...opts, dataKey: 'following_bands', parseItemFn: this.parseFollowingBand }); } static parseFollowingBandsFromContinuation(json, continuation, opts) { return this.parseContinuationItems(json, continuation, { ...opts, dataKey: 'followeers', parseItemFn: this.parseFollowingBand }); } static parseFollowingBand(data, opts) { if (!data) { return null; } const band = { name: data.name || null, location: data.location || '' }; if (data.url_hints && data.url_hints.subdomain) { band.url = `https://${data.url_hints.subdomain}.bandcamp.com`; } if (data.image_id && opts.imageFormat?.id) { band.imageUrl = `${opts.imageBaseUrl}/img/${data.image_id}_${opts.imageFormat.id}.jpg`; } return band; } static parseFollowingGenresFromPage(html, opts) { return this.parsePageItems(html, { ...opts, dataKey: 'following_genres', parseItemFn: this.parseFollowingGenre }); } static parseFollowingGenresFromContinuation(json, continuation, opts) { return this.parseContinuationItems(json, continuation, { ...opts, dataKey: 'followeers', parseItemFn: this.parseFollowingGenre }); } static parseFollowingGenre(data, opts) { if (!data) { return null; } const genre = { type: 'tag', name: data.display_name, value: data.token }; if (Array.isArray(data.art_ids) && opts.imageFormat?.id) { genre.imageUrls = data.art_ids.map((artId) => `${opts.imageBaseUrl}/img/a${artId}_${opts.imageFormat?.id}.jpg`); } return genre; } } exports.default = FanFollowingParser; //# sourceMappingURL=FanFollowingParser.js.map