bandcamp-fetch
Version:
Scrape Bandcamp content
38 lines • 1.91 kB
JavaScript
;
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _a, _ShowListParser_getShowUrl;
Object.defineProperty(exports, "__esModule", { value: true });
const Constants_js_1 = require("../utils/Constants.js");
class ShowListParser {
static parseList(json, opts) {
const shows = [];
if (typeof json === 'object' && Array.isArray(json.results)) {
json.results.forEach((show) => {
const parsed = {
type: 'show',
name: show.title,
url: __classPrivateFieldGet(this, _a, "m", _ShowListParser_getShowUrl).call(this, show.id),
publishedDate: show.published_date,
description: show.desc,
imageCaption: show.image_caption,
subtitle: show.subtitle,
screenImageUrl: `${opts.imageBaseUrl}/img/${show.v2_image_id}_0`
};
if (show.v2_image_id && opts.imageFormat?.id) {
parsed.imageUrl = `${opts.imageBaseUrl}/img/${show.v2_image_id}_${opts.imageFormat.id}.jpg`;
}
shows.push(parsed);
});
}
return shows;
}
}
_a = ShowListParser, _ShowListParser_getShowUrl = function _ShowListParser_getShowUrl(showId) {
return `${Constants_js_1.URLS.SITE_URL}/?show=${showId}`;
};
exports.default = ShowListParser;
//# sourceMappingURL=ShowListParser.js.map