booru
Version:
Search (and do other things) on a bunch of different boorus!
45 lines • 1.48 kB
JavaScript
;
/**
* @packageDocumentation
* @module Boorus
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const Constants_1 = require("../Constants");
const Booru_1 = __importDefault(require("./Booru"));
/**
* A class designed for Derpibooru
* >:(
* @private
* @extends Booru
* @inheritDoc
*/
class Derpibooru extends Booru_1.default {
/** @inheritDoc */
search(tags, { limit = 1, random = false, page = 0 } = {}) {
const tagArray = this.normalizeTags(tags);
// For any image, you must supply *
if (tagArray[0] === undefined) {
tagArray[0] = '*';
}
// Derpibooru offsets the pages by 1
page += 1;
const uri = this.getSearchUrl({ tags: tagArray, limit, page }) +
(random && this.site.random === 'string' ? `&${this.site.random}` : '') +
(this.credentials ? `&key=${this.credentials.token}` : '');
return super
.doSearchRequest(tagArray, { limit, random, page, uri })
.then((r) => super.parseSearchResult(r, {
fakeLimit: 0,
tags: tagArray,
limit,
random,
page,
}))
.catch((e) => Promise.reject(new Constants_1.BooruError(e)));
}
}
exports.default = Derpibooru;
//# sourceMappingURL=Derpibooru.js.map