bandcamp-fetch
Version:
Scrape Bandcamp content
54 lines • 2.96 kB
JavaScript
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
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 _LimiterShowAPI_limiter;
import BaseAPIWithImageSupport from '../common/BaseAPIWithImageSupport.js';
import { URLS } from '../utils/Constants.js';
import ShowListParser from './ShowListParser.js';
import ShowParser from './ShowParser.js';
export default class ShowAPI extends BaseAPIWithImageSupport {
async getShow(params) {
const imageConstants = await this.imageAPI.getConstants();
const opts = {
showUrl: params.showUrl,
imageBaseUrl: imageConstants.baseUrl,
albumImageFormat: await this.imageAPI.getFormat(params.albumImageFormat, 9),
artistImageFormat: await this.imageAPI.getFormat(params.artistImageFormat, 21),
showImageFormat: await this.imageAPI.getFormat(params.showImageFormat, 25)
};
const html = await this.fetch(params.showUrl);
return ShowParser.parseShow(html, opts);
}
async list(params) {
const imageConstants = await this.imageAPI.getConstants();
const opts = {
imageBaseUrl: imageConstants.baseUrl,
imageFormat: await this.imageAPI.getFormat(params?.imageFormat, 25)
};
const json = await this.fetch(URLS.SHOWS, true);
return ShowListParser.parseList(json, opts);
}
}
export class LimiterShowAPI extends ShowAPI {
constructor(params) {
super(params);
_LimiterShowAPI_limiter.set(this, void 0);
__classPrivateFieldSet(this, _LimiterShowAPI_limiter, params.limiter, "f");
}
async getShow(params) {
return __classPrivateFieldGet(this, _LimiterShowAPI_limiter, "f").schedule(() => super.getShow(params));
}
async list(params) {
return __classPrivateFieldGet(this, _LimiterShowAPI_limiter, "f").schedule(() => super.list(params));
}
}
_LimiterShowAPI_limiter = new WeakMap();
//# sourceMappingURL=ShowAPI.js.map