UNPKG

bandcamp-fetch

Version:
62 lines 2.16 kB
import FanItemsBaseParser from './FanItemsBaseParser.js'; export default class FanFollowingParser extends FanItemsBaseParser { 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; } } //# sourceMappingURL=FanFollowingParser.js.map