bandcamp-fetch
Version:
Scrape Bandcamp content
39 lines • 2.34 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 _LimiterAlbumAPI_limiter;
import AlbumInfoParser from './AlbumInfoParser.js';
import BaseAPIWithImageSupport from '../common/BaseAPIWithImageSupport.js';
export default class AlbumAPI extends BaseAPIWithImageSupport {
async getInfo(params) {
const imageConstants = await this.imageAPI.getConstants();
const opts = {
imageBaseUrl: imageConstants.baseUrl,
albumImageFormat: await this.imageAPI.getFormat(params.albumImageFormat, 9),
artistImageFormat: await this.imageAPI.getFormat(params.artistImageFormat, 21),
includeRawData: params.includeRawData !== undefined ? params.includeRawData : false
};
const html = await this.fetch(params.albumUrl);
return AlbumInfoParser.parseInfo(html, opts);
}
}
export class LimiterAlbumAPI extends AlbumAPI {
constructor(params) {
super(params);
_LimiterAlbumAPI_limiter.set(this, void 0);
__classPrivateFieldSet(this, _LimiterAlbumAPI_limiter, params.limiter, "f");
}
async getInfo(params) {
return __classPrivateFieldGet(this, _LimiterAlbumAPI_limiter, "f").schedule(() => super.getInfo(params));
}
}
_LimiterAlbumAPI_limiter = new WeakMap();
//# sourceMappingURL=AlbumAPI.js.map