booru 2.5.1 → 2.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Constants.d.ts +45 -0
- package/dist/Constants.js +1 -0
- package/dist/Constants.js.map +1 -0
- package/dist/Utils.d.ts +56 -0
- package/dist/Utils.js +1 -0
- package/dist/Utils.js.map +1 -0
- package/dist/boorus/Booru.d.ts +69 -1
- package/dist/boorus/Booru.js +1 -1
- package/dist/boorus/Booru.js.map +1 -1
- package/dist/boorus/Derpibooru.d.ts +18 -1
- package/dist/boorus/Derpibooru.js.map +1 -1
- package/dist/boorus/XmlBooru.d.ts +16 -1
- package/dist/boorus/XmlBooru.js.map +1 -1
- package/dist/index.d.ts +37 -1
- package/dist/index.js.map +1 -1
- package/dist/sites.json +1 -0
- package/dist/structures/InternalSearchParameters.d.ts +11 -1
- package/dist/structures/InternalSearchParameters.js.map +1 -1
- package/dist/structures/Post.d.ts +104 -1
- package/dist/structures/Post.js.map +1 -1
- package/dist/structures/SearchParameters.d.ts +13 -1
- package/dist/structures/SearchParameters.js.map +1 -1
- package/dist/structures/SearchResults.d.ts +56 -1
- package/dist/structures/SearchResults.js.map +1 -1
- package/dist/structures/Site.d.ts +35 -0
- package/dist/structures/Site.js +1 -0
- package/dist/structures/Site.js.map +1 -0
- package/dist/structures/SiteApi.d.ts +14 -0
- package/dist/structures/SiteApi.js +1 -0
- package/dist/structures/SiteApi.js.map +1 -0
- package/dist/structures/SiteInfo.d.ts +32 -0
- package/dist/structures/SiteInfo.js +1 -0
- package/dist/structures/SiteInfo.js.map +1 -0
- package/package.json +6 -9
- package/dist/test.d.ts +0 -1
- package/dist/test.js +0 -1
- package/dist/test.js.map +0 -1
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* @module Constants
|
|
4
|
+
*/
|
|
5
|
+
import { RequestInit } from 'node-fetch';
|
|
6
|
+
import Site from './structures/Site';
|
|
7
|
+
import SiteInfo from './structures/SiteInfo';
|
|
8
|
+
export interface SMap<V> {
|
|
9
|
+
[key: string]: V;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* A map of site url/{@link SiteInfo}
|
|
13
|
+
*/
|
|
14
|
+
export declare const sites: SMap<SiteInfo>;
|
|
15
|
+
/**
|
|
16
|
+
* Custom error type for when the boorus error or for user-side error, not my code (probably)
|
|
17
|
+
* <p>The name of the error is 'BooruError'
|
|
18
|
+
* @type {Error}
|
|
19
|
+
*/
|
|
20
|
+
export declare class BooruError extends Error {
|
|
21
|
+
constructor(message: string | Error);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The user-agent to use for searches
|
|
25
|
+
* @private
|
|
26
|
+
*/
|
|
27
|
+
export declare const USER_AGENT = "booru (https://github.com/AtoraSuunva/booru)";
|
|
28
|
+
/**
|
|
29
|
+
* Create a full uri to search with
|
|
30
|
+
*
|
|
31
|
+
* @private
|
|
32
|
+
* @param {string} domain The domain to search
|
|
33
|
+
* @param {Site} site The site to search
|
|
34
|
+
* @param {string[]} [tags=[]] The tags to search for
|
|
35
|
+
* @param {number} [limit=100] The limit for images to return
|
|
36
|
+
* @param {number} [page=0] The page to get
|
|
37
|
+
*/
|
|
38
|
+
export declare function searchURI(site: Site, tags: string[] | undefined, limit: number | undefined, page: number): string;
|
|
39
|
+
/**
|
|
40
|
+
* The default options to use for requests
|
|
41
|
+
* <p>I could document this better but meh
|
|
42
|
+
*
|
|
43
|
+
* @private
|
|
44
|
+
*/
|
|
45
|
+
export declare const defaultOptions: RequestInit;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var __importDefault=this&&this.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.defaultOptions=exports.searchURI=exports.USER_AGENT=exports.BooruError=exports.sites=void 0;const sites_json_1=__importDefault(require("./sites.json")),expandedTags={"rating:e":"rating:explicit","rating:q":"rating:questionable","rating:s":"rating:safe"};exports.sites=sites_json_1.default;class BooruError extends Error{constructor(r){super(r instanceof Error?r.message:r),r instanceof Error?this.stack=r.stack:Error.captureStackTrace(this,BooruError),this.name="BooruError"}}function expandTags(r){return r.map((r=>{const e=expandedTags[r.toLowerCase()];return encodeURIComponent(e||r)}))}function searchURI(r,e=[],t=100,o){return`http${r.insecure?"":"s"}://${r.domain}${r.api.search}${r.tagQuery}=${expandTags(e).join("+")}&limit=${t}&${r.paginate}=${o}`}exports.BooruError=BooruError,exports.USER_AGENT="booru (https://github.com/AtoraSuunva/booru)",exports.searchURI=searchURI,exports.defaultOptions={headers:{Accept:"application/json, application/xml;q=0.9, */*;q=0.8","User-Agent":exports.USER_AGENT}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Constants.js","sourceRoot":"","sources":["../src/Constants.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAGH,8DAAmC;AAgBnC,MAAM,YAAY,GAAY;IAC5B,UAAU,EAAE,iBAAiB;IAC7B,UAAU,EAAE,qBAAqB;IACjC,UAAU,EAAE,aAAa;CAC1B,CAAA;AAED;;GAEG;AACU,QAAA,KAAK,GAAG,oBAAqC,CAAA;AAE1D;;;;GAIG;AACH,MAAa,UAAW,SAAQ,KAAK;IACnC,YAAY,OAAuB;QACjC,KAAK,CAAC,OAAO,YAAY,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;QAE3D,IAAI,OAAO,YAAY,KAAK,EAAE;YAC5B,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAA;SAC3B;aAAM;YACL,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAA;SAC1C;QAED,IAAI,CAAC,IAAI,GAAG,YAAY,CAAA;IAC1B,CAAC;CACF;AAZD,gCAYC;AAED;;;GAGG;AACU,QAAA,UAAU,GAAG,8CAA8C,CAAA;AAExE;;;;;GAKG;AACH,SAAS,UAAU,CAAC,IAAc;IAChC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QACpB,MAAM,EAAE,GAAG,YAAY,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAA;QACxC,OAAO,kBAAkB,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IACxC,CAAC,CAAC,CAAA;AACJ,CAAC;AAED;;;;;;;;;GASG;AACH,SAAgB,SAAS,CACvB,IAAU,EACV,OAAiB,EAAE,EACnB,KAAK,GAAG,GAAG,EACX,IAAY;IAEZ,OAAO,CACL,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK;QACpC,GAAG,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE;QAClC,GAAG,IAAI,CAAC,QAAQ,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QAChD,UAAU,KAAK,EAAE;QACjB,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,EAAE,CAC5B,CAAA;AACH,CAAC;AAbD,8BAaC;AAED;;;;;GAKG;AACU,QAAA,cAAc,GAAgB;IACzC,OAAO,EAAE;QACP,MAAM,EAAE,oDAAoD;QAC5D,YAAY,EAAE,kBAAU;KACzB;CACF,CAAA"}
|
package/dist/Utils.d.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* @module Utils
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Check if `site` is a supported site (and check if it's an alias and return the sites's true name)
|
|
7
|
+
*
|
|
8
|
+
* @param {String} domain The site to resolveSite
|
|
9
|
+
* @return {String?} null if site is not supported, the site otherwise
|
|
10
|
+
*/
|
|
11
|
+
export declare function resolveSite(domain: string): string | null;
|
|
12
|
+
/**
|
|
13
|
+
* Parses xml to json, which can be used with js
|
|
14
|
+
*
|
|
15
|
+
* @private
|
|
16
|
+
* @param {String} xml The xml to convert to json
|
|
17
|
+
* @return {Object[]} A Promise with an array of objects created from the xml
|
|
18
|
+
*/
|
|
19
|
+
export declare function jsonfy(xml: string): object[];
|
|
20
|
+
/**
|
|
21
|
+
* Yay fisher-bates
|
|
22
|
+
* Taken from http://stackoverflow.com/a/2450976
|
|
23
|
+
*
|
|
24
|
+
* @private
|
|
25
|
+
* @param {Array} array Array of something
|
|
26
|
+
* @return {Array} Shuffled array of something
|
|
27
|
+
*/
|
|
28
|
+
export declare function shuffle<T>(array: T[]): T[];
|
|
29
|
+
/**
|
|
30
|
+
* Generate a random int between [min, max]
|
|
31
|
+
*
|
|
32
|
+
* @private
|
|
33
|
+
* @param {Number} min The minimum (inclusive)
|
|
34
|
+
* @param {Number} max The maximum (inclusive)
|
|
35
|
+
*/
|
|
36
|
+
export declare function randInt(min: number, max: number): number;
|
|
37
|
+
/**
|
|
38
|
+
* Performs some basic search validation
|
|
39
|
+
*
|
|
40
|
+
* @private
|
|
41
|
+
* @param {String} site The site to resolve
|
|
42
|
+
* @param {Number|String} limit The limit for the amount of images to fetch
|
|
43
|
+
*/
|
|
44
|
+
export declare function validateSearchParams(site: string, limit: number | string): {
|
|
45
|
+
site: string;
|
|
46
|
+
limit: number;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Finds the matching strings between two arrays
|
|
50
|
+
*
|
|
51
|
+
* @private
|
|
52
|
+
* @param {String[]} arr1 The first array
|
|
53
|
+
* @param {String[]} arr2 The second array
|
|
54
|
+
* @return {String[]} The shared strings between the arrays
|
|
55
|
+
*/
|
|
56
|
+
export declare function compareArrays(arr1: string[], arr2: string[]): string[];
|
package/dist/Utils.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.compareArrays=exports.validateSearchParams=exports.randInt=exports.shuffle=exports.jsonfy=exports.resolveSite=void 0;const Constants_1=require("./Constants"),fast_xml_parser_1=require("fast-xml-parser");function resolveSite(t){if("string"!=typeof t)return null;t=t.toLowerCase();for(const r in Constants_1.sites)if(r===t||Constants_1.sites[r].domain===t||Constants_1.sites[r].aliases.includes(t))return r;return null}function jsonfy(t){if("object"==typeof t)return t;const r=(0,fast_xml_parser_1.parse)(t,{ignoreAttributes:!1,attributeNamePrefix:""});if(r.html||r["!doctype"]){const t=r.html||r["!doctype"]?.html,e=[];throw t.body.h1&&e.push(t.body.h1),t.body.p&&e.push(t.body.p["#text"]),new Constants_1.BooruError(`The Booru sent back an error: '${e.join(": ")}'`)}return r.posts.post?r.posts.post:r.posts.tag?Array.isArray(r.posts.tag)?r.posts.tag:[r.posts.tag]:[]}function shuffle(t){let r,e,o=t.length;for(;0!==o;)e=Math.floor(Math.random()*o),o-=1,r=t[o],t[o]=t[e],t[e]=r;return t}function randInt(t,r){return t=Math.ceil(t),r=Math.floor(r),Math.floor(Math.random()*(r-t+1))+t}function validateSearchParams(t,r){const e=resolveSite(t);if("number"!=typeof r&&(r=parseInt(r,10)),null===e)throw new Constants_1.BooruError("Site not supported");if("number"!=typeof r||Number.isNaN(r))throw new Constants_1.BooruError("`limit` should be an int");return{site:e,limit:r}}function compareArrays(t,r){return t.filter((t=>r.some((r=>t.toLowerCase()===r.toLowerCase()))))}exports.resolveSite=resolveSite,exports.jsonfy=jsonfy,exports.shuffle=shuffle,exports.randInt=randInt,exports.validateSearchParams=validateSearchParams,exports.compareArrays=compareArrays;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Utils.js","sourceRoot":"","sources":["../src/Utils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2CAA+C;AAE/C,qDAAmD;AAEnD;;;;;GAKG;AACH,SAAgB,WAAW,CAAC,MAAc;IACxC,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;QAC9B,OAAO,IAA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;AACH,SAAgB,oBAAoB,CAClC,IAAY,EACZ,KAAsB;IAEtB,MAAM,YAAY,GAAG,WAAW,CAAC,IAAI,CAAC,CAAA;IAEtC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC7B,KAAK,GAAG,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;KAC5B;IAED,IAAI,YAAY,KAAK,IAAI,EAAE;QACzB,MAAM,IAAI,sBAAU,CAAC,oBAAoB,CAAC,CAAA;KAC3C;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;QACpD,MAAM,IAAI,sBAAU,CAAC,0BAA0B,CAAC,CAAA;KACjD;IAED,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,CAAA;AACtC,CAAC;AAnBD,oDAmBC;AAED;;;;;;;GAOG;AACH,SAAgB,aAAa,CAAC,IAAc,EAAE,IAAc;IAC1D,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CACxB,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,WAAW,EAAE,KAAK,EAAE,CAAC,WAAW,EAAE,CAAC,CACzD,CAAA;AACH,CAAC;AAJD,sCAIC"}
|
package/dist/boorus/Booru.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* @module Boorus
|
|
4
|
+
*/
|
|
5
|
+
import InternalSearchParameters from '../structures/InternalSearchParameters';
|
|
2
6
|
import SearchParameters from '../structures/SearchParameters';
|
|
3
7
|
import SearchResults from '../structures/SearchResults';
|
|
4
8
|
import Site from '../structures/Site';
|
|
@@ -10,15 +14,79 @@ interface SearchUrlParams {
|
|
|
10
14
|
limit: number;
|
|
11
15
|
page: number;
|
|
12
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* A basic, JSON booru
|
|
19
|
+
* @example
|
|
20
|
+
* ```
|
|
21
|
+
* const Booru = require('booru')
|
|
22
|
+
* // Aliases are supported
|
|
23
|
+
* const e9 = Booru('e9')
|
|
24
|
+
*
|
|
25
|
+
* // You can then search the site
|
|
26
|
+
* const imgs = await e9.search(['cat', 'cute'], {limit: 3})
|
|
27
|
+
*
|
|
28
|
+
* // And use the images
|
|
29
|
+
* imgs.forEach(i => console.log(i.fileUrl))
|
|
30
|
+
*
|
|
31
|
+
* // Or access other methods on the Booru
|
|
32
|
+
* e9.postView(imgs[0].id)
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
13
35
|
export declare class Booru {
|
|
36
|
+
/** The domain of the booru */
|
|
14
37
|
domain: string;
|
|
38
|
+
/** The site object representing this booru */
|
|
15
39
|
site: Site;
|
|
40
|
+
/** The credentials to use for this booru */
|
|
16
41
|
credentials?: BooruCredentials;
|
|
42
|
+
/**
|
|
43
|
+
* Create a new booru from a site
|
|
44
|
+
*
|
|
45
|
+
* @private
|
|
46
|
+
* @param site The site to use
|
|
47
|
+
* @param credentials Credentials for the API (Currently not used)
|
|
48
|
+
*/
|
|
17
49
|
constructor(site: Site, credentials?: BooruCredentials);
|
|
50
|
+
/**
|
|
51
|
+
* Search for images on this booru
|
|
52
|
+
* @param {String|String[]} tags The tag(s) to search for
|
|
53
|
+
* @param {SearchParameters} searchArgs The arguments for the search
|
|
54
|
+
* @return {Promise<SearchResults>} The results as an array of Posts
|
|
55
|
+
*/
|
|
18
56
|
search(tags: string | string[], { limit, random, page, showUnavailable, }?: SearchParameters): Promise<SearchResults>;
|
|
57
|
+
/**
|
|
58
|
+
* Gets the url you'd see in your browser from a post id for this booru
|
|
59
|
+
*
|
|
60
|
+
* @param {String} id The id to get the postView for
|
|
61
|
+
* @return {String} The url to the post
|
|
62
|
+
*/
|
|
19
63
|
postView(id: string | number): string;
|
|
64
|
+
/**
|
|
65
|
+
* The internal & common searching logic, pls dont use this use .search instead
|
|
66
|
+
*
|
|
67
|
+
* @protected
|
|
68
|
+
* @param {String[]|String} tags The tags to search with
|
|
69
|
+
* @param {InternalSearchParameters} searchArgs The arguments for the search
|
|
70
|
+
* @return {Promise<Object>}
|
|
71
|
+
*/
|
|
20
72
|
protected doSearchRequest(tags: string[] | string, { uri, limit, random, page, }?: InternalSearchParameters): Promise<any>;
|
|
73
|
+
/**
|
|
74
|
+
* Generates a URL to search the booru with, mostly for debugging purposes
|
|
75
|
+
* @param opt
|
|
76
|
+
* @param {string[]} [opt.tags] The tags to search for
|
|
77
|
+
* @param {number} [opt.limit] The limit of results to return
|
|
78
|
+
* @param {number} [opt.page] The page of results to return
|
|
79
|
+
* @returns A URL to search the booru
|
|
80
|
+
*/
|
|
21
81
|
getSearchUrl({ tags, limit, page, }: Partial<SearchUrlParams>): string;
|
|
82
|
+
/**
|
|
83
|
+
* Parse the response from the booru
|
|
84
|
+
*
|
|
85
|
+
* @protected
|
|
86
|
+
* @param {Object} result The response of the booru
|
|
87
|
+
* @param {InternalSearchParameters} searchArgs The arguments used for the search
|
|
88
|
+
* @return {SearchResults} The results of this search
|
|
89
|
+
*/
|
|
22
90
|
protected parseSearchResult(result: any, { fakeLimit, tags, limit, random, page, showUnavailable, }: InternalSearchParameters): SearchResults;
|
|
23
91
|
}
|
|
24
92
|
export default Booru;
|
package/dist/boorus/Booru.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var __importDefault=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.Booru=void 0;const node_fetch_1=__importDefault(require("node-fetch")),Constants_1=require("../Constants"),Utils_1=require("../Utils"),Post_1=__importDefault(require("../structures/Post")),SearchResults_1=__importDefault(require("../structures/SearchResults")),resolvedFetch="undefined"!=typeof window?window.fetch.bind(window):node_fetch_1.default;class Booru{domain;site;credentials;constructor(t,e){const s=(0,Utils_1.resolveSite)(t.domain);if(null===s)throw new Error(`Invalid site passed: ${t}`);this.domain=s,this.site=t,this.credentials=e}async search(t,{limit:e=1,random:s=!1,page:r=0,showUnavailable:i=!1}={}){const o=s&&!this.site.random?100:0;try{const a=await this.doSearchRequest(t,{limit:e,random:s,page:r,showUnavailable:i});return this.parseSearchResult(a,{fakeLimit:o,tags:t,limit:e,random:s,page:r,showUnavailable:i})}catch(t){throw t instanceof Error?new Constants_1.BooruError(t):t}}postView(t){if("string"==typeof t&&Number.isNaN(parseInt(t,10)))throw new Constants_1.BooruError(`Not a valid id for postView: ${t}`);return`http${this.site.insecure?"":"s"}://${this.domain}${this.site.api.postView}${t}`}async doSearchRequest(t,{uri:e=null,limit:s=1,random:r=!1,page:i=0}={}){let o;Array.isArray(t)||(t=[t]),r&&(this.site.random?t.push("order:random"):o=100),this.site.defaultTags&&(t=t.concat(this.site.defaultTags.filter((e=>!t.includes(e)))));const a=e||this.getSearchUrl({tags:t,limit:o||s,page:i}),n=Constants_1.defaultOptions,l="xml"===this.site.type;try{const t=await resolvedFetch(a,n);if(503===t.status
|
|
1
|
+
"use strict";var __importDefault=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.Booru=void 0;const node_fetch_1=__importDefault(require("node-fetch")),Constants_1=require("../Constants"),Utils_1=require("../Utils"),Post_1=__importDefault(require("../structures/Post")),SearchResults_1=__importDefault(require("../structures/SearchResults")),resolvedFetch="undefined"!=typeof window?window.fetch.bind(window):node_fetch_1.default;class Booru{domain;site;credentials;constructor(t,e){const s=(0,Utils_1.resolveSite)(t.domain);if(null===s)throw new Error(`Invalid site passed: ${t}`);this.domain=s,this.site=t,this.credentials=e}async search(t,{limit:e=1,random:s=!1,page:r=0,showUnavailable:i=!1}={}){const o=s&&!this.site.random?100:0;try{const a=await this.doSearchRequest(t,{limit:e,random:s,page:r,showUnavailable:i});return this.parseSearchResult(a,{fakeLimit:o,tags:t,limit:e,random:s,page:r,showUnavailable:i})}catch(t){throw t instanceof Error?new Constants_1.BooruError(t):t}}postView(t){if("string"==typeof t&&Number.isNaN(parseInt(t,10)))throw new Constants_1.BooruError(`Not a valid id for postView: ${t}`);return`http${this.site.insecure?"":"s"}://${this.domain}${this.site.api.postView}${t}`}async doSearchRequest(t,{uri:e=null,limit:s=1,random:r=!1,page:i=0}={}){let o;Array.isArray(t)||(t=[t]),r&&(this.site.random?t.push("order:random"):o=100),this.site.defaultTags&&(t=t.concat(this.site.defaultTags.filter((e=>!t.includes(e)))));const a=e||this.getSearchUrl({tags:t,limit:o||s,page:i}),n=Constants_1.defaultOptions,l="xml"===this.site.type;try{const t=await resolvedFetch(a,n);if(503===t.status&&(await t.clone().text()).includes("cf-browser-verification"))throw new Constants_1.BooruError("Received a CloudFlare browser verification request. Can't proceed.");const e=l?await t.text():await t.json(),s=l?(0,Utils_1.jsonfy)(e):e;if(t.ok)return s;throw new Constants_1.BooruError(`Received HTTP ${t.status} from booru: '${s.error||s.message||JSON.stringify(s)}'`)}catch(t){if("invalid-json"===t.type)return"";throw t}}getSearchUrl({tags:t=[],limit:e=100,page:s=1}){return(0,Constants_1.searchURI)(this.site,t,e,s)}parseSearchResult(t,{fakeLimit:e,tags:s,limit:r,random:i,page:o,showUnavailable:a}){if(!1===t.success)throw new Constants_1.BooruError(t.message||t.reason);let n;t["@attributes"]&&(t="0"!==t["@attributes"].count&&t.post?Array.isArray(t.post)?t.post:[t.post]:[]),t.posts&&(t=t.posts),t.images&&(t=t.images),""===t?n=[]:e?n=(0,Utils_1.shuffle)(t):t.constructor===Object&&(n=[t]);let l=(n||t).slice(0,r).map((t=>new Post_1.default(t,this)));const u={limit:r,random:i,page:o,showUnavailable:a};return void 0===s&&(s=[]),Array.isArray(s)||(s=[s]),a||(l=l.filter((t=>t.available))),new SearchResults_1.default(l,s,u,this)}}exports.Booru=Booru,exports.default=Booru;
|
package/dist/boorus/Booru.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Booru.js","sourceRoot":"","sources":["../../src/boorus/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,kBAAe,KAAK,CAAA"}
|
|
@@ -1,8 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* @module Boorus
|
|
4
|
+
*/
|
|
5
|
+
import SearchParameters from '../structures/SearchParameters';
|
|
2
6
|
import SearchResults from '../structures/SearchResults';
|
|
3
7
|
import Site from '../structures/Site';
|
|
4
8
|
import Booru, { BooruCredentials } from './Booru';
|
|
9
|
+
/**
|
|
10
|
+
* A class designed for Derpibooru
|
|
11
|
+
* >:(
|
|
12
|
+
* @private
|
|
13
|
+
* @extends Booru
|
|
14
|
+
* @inheritDoc
|
|
15
|
+
*/
|
|
5
16
|
export default class Derpibooru extends Booru {
|
|
17
|
+
/**
|
|
18
|
+
* Create a new booru for Derpibooru from a site
|
|
19
|
+
* @param site The site to use
|
|
20
|
+
* @param credentials Credentials for the API (Currently not used)
|
|
21
|
+
*/
|
|
6
22
|
constructor(site: Site, credentials?: BooruCredentials);
|
|
23
|
+
/** @inheritDoc */
|
|
7
24
|
search(tags: string[] | string, { limit, random, page }?: SearchParameters): Promise<SearchResults>;
|
|
8
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Derpibooru.js","sourceRoot":"","sources":["../../src/boorus/Derpibooru.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"Derpibooru.js","sourceRoot":"","sources":["../../src/boorus/Derpibooru.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;AAEH,4CAAyC;AAIzC,oDAAiD;AAEjD;;;;;;GAMG;AACH,MAAqB,UAAW,SAAQ,eAAK;IAC3C;;;;OAIG;IACH,YAAY,IAAU,EAAE,WAA8B;QACpD,KAAK,CAAC,IAAI,EAAE,WAAW,CAAC,CAAA;IAC1B,CAAC;IAED,kBAAkB;IACF,MAAM,CACpB,IAAuB,EACvB,EAAE,KAAK,GAAG,CAAC,EAAE,MAAM,GAAG,KAAK,EAAE,IAAI,GAAG,CAA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
import Site from '../structures/Site';
|
|
2
6
|
import Booru, { BooruCredentials } from './Booru';
|
|
7
|
+
/**
|
|
8
|
+
* A class designed for Xml-returning boorus
|
|
9
|
+
*
|
|
10
|
+
* @extends Booru
|
|
11
|
+
* @inheritDoc
|
|
12
|
+
*/
|
|
3
13
|
export default class XmlBooru extends Booru {
|
|
14
|
+
/**
|
|
15
|
+
* Create a new booru using XML from a site
|
|
16
|
+
* @param {Site} site The site to use
|
|
17
|
+
* @param {Object?} credentials Credentials for the API (Currently not used)
|
|
18
|
+
*/
|
|
4
19
|
constructor(site: Site, credentials?: BooruCredentials);
|
|
5
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"XmlBooru.js","sourceRoot":"","sources":["../../src/boorus/XmlBooru.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"XmlBooru.js","sourceRoot":"","sources":["../../src/boorus/XmlBooru.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;AAGH,oDAAiD;AAEjD;;;;;GAKG;AACH,MAAqB,QAAS,SAAQ,eAAK;IACzC;;;;OAIG;IACH,YAAY,IAAU,EAAE,WAA8B;QACpD,KAAK,CAAC,IAAI,EAAE,WAAW,CAAC,CAAA;IAC1B,CAAC;CACF;AATD,2BASC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,47 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* @module Index
|
|
4
|
+
*/
|
|
5
|
+
import Booru from './boorus/Booru';
|
|
2
6
|
import Post from './structures/Post';
|
|
3
7
|
import SearchParameters from './structures/SearchParameters';
|
|
4
8
|
import SearchResults from './structures/SearchResults';
|
|
9
|
+
/**
|
|
10
|
+
* Create a new booru to search with
|
|
11
|
+
*
|
|
12
|
+
* @constructor
|
|
13
|
+
* @param {String} site The {@link Site} domain (or alias of it) to create a booru from
|
|
14
|
+
* @param {*} credentials The credentials to use on this booru
|
|
15
|
+
* @return {Booru} A booru to use
|
|
16
|
+
*/
|
|
5
17
|
declare function booruForSite(site: string, credentials?: any): Booru;
|
|
6
18
|
export { booruForSite as forSite };
|
|
7
19
|
export default booruForSite;
|
|
20
|
+
/**
|
|
21
|
+
* Searches a site for images with tags and returns the results
|
|
22
|
+
* @param {String} site The site to search
|
|
23
|
+
* @param {String[]|String} [tags=[]] Tags to search with
|
|
24
|
+
* @param {SearchParameters} [searchOptions={}] The options for searching
|
|
25
|
+
* if provided (Unused)
|
|
26
|
+
* @return {Promise<SearchResults>} A promise with the images as an array of objects
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```
|
|
30
|
+
* const Booru = require('booru')
|
|
31
|
+
* // Returns a promise with the latest cute glace pic from e926
|
|
32
|
+
* Booru.search('e926', ['glaceon', 'cute'])
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
8
35
|
export declare function search(site: string, tags?: string[] | string, { limit, random, page, credentials }?: SearchParameters): Promise<SearchResults>;
|
|
36
|
+
/**
|
|
37
|
+
* Deprecated, now a noop
|
|
38
|
+
* <p>This will be removed *soon* please stop using it</p>
|
|
39
|
+
* <p>Just access <code><{@link Post}>.prop</code>, no need to commonfy anymore
|
|
40
|
+
*
|
|
41
|
+
* @deprecated Just use <code><{@link Post}>.prop</code> instead
|
|
42
|
+
* @param {Post[]} images Array of {@link Post} objects
|
|
43
|
+
* @return {Promise<Post[]>} Array of {@link Post} objects
|
|
44
|
+
*/
|
|
9
45
|
export declare function commonfy(images: Post[]): Promise<Post[]>;
|
|
10
46
|
export { Booru as BooruClass } from './boorus/Booru';
|
|
11
47
|
export { sites } from './Constants';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH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dist/sites.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"e621.net":{"domain":"e621.net","aliases":["e6","e621"],"nsfw":true,"api":{"search":"/posts.json?","postView":"/post/show/"},"random":true},"e926.net":{"domain":"e926.net","aliases":["e9","e926"],"nsfw":false,"api":{"search":"/posts.json?","postView":"/post/show/"},"random":true,"defaultTags":["rating:safe"]},"hypnohub.net":{"domain":"hypnohub.net","aliases":["hh","hypno","hypnohub"],"nsfw":true,"api":{"search":"/post/index.json?","postView":"/post/show/"},"random":true},"danbooru.donmai.us":{"domain":"danbooru.donmai.us","aliases":["db","dan","danbooru"],"nsfw":true,"api":{"search":"/posts.json?","postView":"/posts/"},"random":true},"konachan.com":{"domain":"konachan.com","aliases":["kc","konac","kcom"],"nsfw":true,"api":{"search":"/post.json?","postView":"/post/show/"},"random":true},"konachan.net":{"domain":"konachan.net","aliases":["kn","konan","knet"],"nsfw":false,"api":{"search":"/post.json?","postView":"/post/show/"},"random":true},"yande.re":{"domain":"yande.re","aliases":["yd","yand","yandere"],"nsfw":true,"api":{"search":"/post.json?","postView":"/post/show/"},"random":true},"gelbooru.com":{"domain":"gelbooru.com","aliases":["gb","gel","gelbooru"],"nsfw":true,"api":{"search":"/index.php?page=dapi&s=post&q=index&json=1&","postView":"/index.php?page=post&s=view&json=1&id="},"paginate":"pid","random":false},"rule34.xxx":{"domain":"api.rule34.xxx","aliases":["r34","rule34"],"nsfw":true,"api":{"search":"/index.php?page=dapi&s=post&q=index&json=1&","postView":"/index.php?page=post&s=view&json=1&id="},"paginate":"pid","random":false},"safebooru.org":{"domain":"safebooru.org","aliases":["sb","safe","safebooru"],"nsfw":false,"api":{"search":"/index.php?page=dapi&s=post&q=index&json=1&","postView":"/index.php?page=post&s=view&json=1&id="},"paginate":"pid","random":false},"tbib.org":{"domain":"tbib.org","aliases":["tb","tbib","big"],"nsfw":false,"api":{"search":"/index.php?page=dapi&s=post&q=index&json=1&","postView":"/index.php?page=post&s=view&json=1&id="},"paginate":"pid","random":false},"xbooru.com":{"domain":"xbooru.com","aliases":["xb","xbooru"],"nsfw":true,"api":{"search":"/index.php?page=dapi&s=post&q=index&json=1&","postView":"/index.php?page=post&s=view&json=1&id="},"paginate":"pid","random":false},"rule34.paheal.net":{"domain":"rule34.paheal.net","type":"xml","aliases":["pa","paheal"],"nsfw":true,"api":{"search":"/api/danbooru/find_posts/index.xml?","postView":"/post/view/"},"random":false},"derpibooru.org":{"domain":"derpibooru.org","type":"derpi","aliases":["dp","derp","derpi","derpibooru"],"nsfw":true,"api":{"search":"/api/v1/json/search/images?","postView":"/images/"},"tagQuery":"q","random":"sf=random"},"realbooru.com":{"domain":"realbooru.com","aliases":["rb","realbooru"],"nsfw":true,"api":{"search":"/index.php?page=dapi&s=post&q=index&json=1&","postView":"/index.php?page=post&s=view&id="},"paginate":"pid","random":false}}
|
|
@@ -1,6 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* @module Structures
|
|
4
|
+
*/
|
|
5
|
+
import SearchParameters from './SearchParameters';
|
|
6
|
+
/**
|
|
7
|
+
* Interface for {@link Booru}'s **private internal** search params pls no use
|
|
8
|
+
*/
|
|
2
9
|
export default interface InternalSearchParameters extends SearchParameters {
|
|
10
|
+
/** The uri to override with, if provided */
|
|
3
11
|
uri?: string | null;
|
|
12
|
+
/** If `order:random` should be faked */
|
|
4
13
|
fakeLimit?: number;
|
|
14
|
+
/** The tags used in the search */
|
|
5
15
|
tags?: string[] | string;
|
|
6
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InternalSearchParameters.js","sourceRoot":"","sources":["../../src/structures/InternalSearchParameters.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"InternalSearchParameters.js","sourceRoot":"","sources":["../../src/structures/InternalSearchParameters.ts"],"names":[],"mappings":";AAAA;;;GAGG"}
|
|
@@ -1,31 +1,134 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* @module Structures
|
|
4
|
+
*/
|
|
5
|
+
import Booru from '../boorus/Booru';
|
|
6
|
+
/**
|
|
7
|
+
* An image from a booru with a few common props
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```
|
|
11
|
+
* Post {
|
|
12
|
+
* fileUrl: 'https://aaaa.com/image.jpg',
|
|
13
|
+
* id: '124125',
|
|
14
|
+
* tags: ['cat', 'cute'],
|
|
15
|
+
* score: 5,
|
|
16
|
+
* source: 'https://giraffeduck.com/aaaa.png',
|
|
17
|
+
* rating: 's'
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
2
21
|
export default class Post {
|
|
22
|
+
/** The {@link Booru} it came from */
|
|
3
23
|
booru: Booru;
|
|
24
|
+
/** The direct link to the file */
|
|
4
25
|
fileUrl: string | null;
|
|
26
|
+
/** The height of the file */
|
|
5
27
|
height: number;
|
|
28
|
+
/** The width of the file */
|
|
6
29
|
width: number;
|
|
30
|
+
/** The url to the medium-sized image (if available) */
|
|
7
31
|
sampleUrl: string | null;
|
|
32
|
+
/** The height of the medium-sized image (if available) */
|
|
8
33
|
sampleHeight: number | null;
|
|
34
|
+
/** The width of the medium-sized image (if available) */
|
|
9
35
|
sampleWidth: number | null;
|
|
36
|
+
/** The url to the smallest image (if available) */
|
|
10
37
|
previewUrl: string | null;
|
|
38
|
+
/** The height of the smallest image (if available) */
|
|
11
39
|
previewHeight: number | null;
|
|
40
|
+
/** The width of the smallest image (if available) */
|
|
12
41
|
previewWidth: number | null;
|
|
42
|
+
/** The id of this post */
|
|
13
43
|
id: string;
|
|
44
|
+
/** If this post is available (ie. not deleted, not banned, has file url) */
|
|
14
45
|
available: boolean;
|
|
46
|
+
/** The tags of this post */
|
|
15
47
|
tags: string[];
|
|
48
|
+
/** The score of this post */
|
|
16
49
|
score: number;
|
|
50
|
+
/** The source of this post, if available */
|
|
17
51
|
source?: string | string[];
|
|
52
|
+
/**
|
|
53
|
+
* The rating of the image, as just the first letter
|
|
54
|
+
* (s/q/e/u) => safe/questionable/explicit/unrated
|
|
55
|
+
*/
|
|
18
56
|
rating: string;
|
|
57
|
+
/** The Date this post was created at */
|
|
19
58
|
createdAt?: Date | null;
|
|
59
|
+
/** All the data given by the booru @private */
|
|
20
60
|
protected data: any;
|
|
61
|
+
/**
|
|
62
|
+
* Create an image from a booru
|
|
63
|
+
*
|
|
64
|
+
* @param {Object} data The raw data from the Booru
|
|
65
|
+
* @param {Booru} booru The booru that created the image
|
|
66
|
+
*/
|
|
21
67
|
constructor(data: any, booru: Booru);
|
|
68
|
+
/**
|
|
69
|
+
* The direct link to the file
|
|
70
|
+
* <p>It's prefered to use `.fileUrl` instead because camelCase
|
|
71
|
+
*/
|
|
22
72
|
get file_url(): string | null;
|
|
73
|
+
/**
|
|
74
|
+
* The url to the medium-sized image (if available)
|
|
75
|
+
* <p>It's prefered to use `.sampleUrl` instead because camelCase
|
|
76
|
+
*/
|
|
23
77
|
get sample_url(): string | null;
|
|
78
|
+
/**
|
|
79
|
+
* The height of the medium-sized image (if available)
|
|
80
|
+
* <p>It's prefered to use `.sampleHeight` instead because camelCase
|
|
81
|
+
*/
|
|
24
82
|
get sample_height(): number | null;
|
|
83
|
+
/**
|
|
84
|
+
* The width of the medium-sized image (if available)
|
|
85
|
+
* <p>It's prefered to use `.sampleWidth` instead because camelCase
|
|
86
|
+
*/
|
|
25
87
|
get sample_width(): number | null;
|
|
88
|
+
/**
|
|
89
|
+
* The url to the smallest image (if available)
|
|
90
|
+
* <p>It's prefered to use `.previewUrl` instead because camelCase
|
|
91
|
+
*/
|
|
26
92
|
get preview_url(): string | null;
|
|
93
|
+
/**
|
|
94
|
+
* The height of the smallest image (if available)
|
|
95
|
+
* <p>It's prefered to use `.previewHeight` instead because camelCase
|
|
96
|
+
*/
|
|
27
97
|
get preview_height(): number | null;
|
|
98
|
+
/**
|
|
99
|
+
* The width of the smallest image (if available)
|
|
100
|
+
* <p>It's prefered to use `.previewWidth` instead because camelCase
|
|
101
|
+
*/
|
|
28
102
|
get preview_width(): number | null;
|
|
103
|
+
/**
|
|
104
|
+
* Get the post view (url to the post) of this image
|
|
105
|
+
*
|
|
106
|
+
* @type {String}
|
|
107
|
+
* @example
|
|
108
|
+
* ```
|
|
109
|
+
* const e9 = Booru('e9')
|
|
110
|
+
* const imgs = e9.search(['cat', 'dog'])
|
|
111
|
+
*
|
|
112
|
+
* // Log the post url of the first image
|
|
113
|
+
* console.log(imgs[0].postView)
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
29
116
|
get postView(): string;
|
|
117
|
+
/**
|
|
118
|
+
* Get some common props on the image
|
|
119
|
+
*
|
|
120
|
+
* @deprecated All common props are now attached directly to the image
|
|
121
|
+
* @type {Object}
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```
|
|
125
|
+
* image.id
|
|
126
|
+
* // deprecated, use this instead
|
|
127
|
+
* image.id
|
|
128
|
+
*
|
|
129
|
+
* // To access the post's raw data from the booru, do
|
|
130
|
+
* image._data.id
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
30
133
|
get common(): this;
|
|
31
134
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Post.js","sourceRoot":"","sources":["../../src/structures/Post.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"Post.js","sourceRoot":"","sources":["../../src/structures/Post.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAEH,+BAAgC;AAGhC,yEAAyE;AACzE,MAAM,MAAM,GAAG,IAAA,gBAAS,EAAC,GAAG,EAAE;AAC9B,CAAC,EAAE,+DAA+D,CAAC,CAAA;AAEnE;;;;;;GAMG;AACH,SAAS,aAAa,CAAC,GAAW,EAAE,IAAS,EAAE,KAAY;IACzD,sFAAsF;IACtF,oCAAoC;IACpC,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,IAA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
+
import { BooruCredentials } from '../boorus/Booru';
|
|
6
|
+
/**
|
|
7
|
+
* Just an interface for {@link Booru}'s search params :)
|
|
8
|
+
*/
|
|
2
9
|
export default interface SearchParameters {
|
|
10
|
+
/** The limit on *max* posts to show, you might get less posts than this */
|
|
3
11
|
limit?: number;
|
|
12
|
+
/** Should posts be in random order, implementation differs per booru */
|
|
4
13
|
random?: boolean;
|
|
14
|
+
/** Which page of results to fetch */
|
|
5
15
|
page?: number;
|
|
16
|
+
/** The credentials to use to auth with the booru */
|
|
6
17
|
credentials?: BooruCredentials;
|
|
18
|
+
/** Return unavailable posts (ie. banned/deleted posts) */
|
|
7
19
|
showUnavailable?: boolean;
|
|
8
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchParameters.js","sourceRoot":"","sources":["../../src/structures/SearchParameters.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"SearchParameters.js","sourceRoot":"","sources":["../../src/structures/SearchParameters.ts"],"names":[],"mappings":";AAAA;;;GAGG"}
|
|
@@ -1,18 +1,73 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* @module Structures
|
|
4
|
+
*/
|
|
5
|
+
import Booru from '../boorus/Booru';
|
|
2
6
|
import Post from '../structures/Post';
|
|
3
7
|
import SearchParameters from './SearchParameters';
|
|
8
|
+
/**
|
|
9
|
+
* Represents a page of search results, works like an array of {@link Post}
|
|
10
|
+
* <p> Usable like an array and allows to easily get the next page
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```
|
|
14
|
+
* const Booru = require('booru')
|
|
15
|
+
* // Safebooru
|
|
16
|
+
* const sb = new Booru('sb')
|
|
17
|
+
*
|
|
18
|
+
* const imgs = await sb.search('cat')
|
|
19
|
+
*
|
|
20
|
+
* // Log the images from the first page, then from the second
|
|
21
|
+
* imgs.forEach(i => console.log(i.postView))
|
|
22
|
+
* const imgs2 = await imgs.nextPage()
|
|
23
|
+
* imgs2.forEach(i => console.log(i.postView))
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
4
26
|
export default class SearchResults extends Array<Post> {
|
|
27
|
+
/** The booru used for this search */
|
|
5
28
|
booru: Booru;
|
|
29
|
+
/** The page of this search */
|
|
6
30
|
page: number;
|
|
31
|
+
/** The tags used for this search */
|
|
7
32
|
readonly tags: string[];
|
|
33
|
+
/** The options used for this search */
|
|
8
34
|
readonly options: SearchParameters;
|
|
35
|
+
/** The posts from this search result */
|
|
9
36
|
readonly posts: Post[];
|
|
37
|
+
/** @private */
|
|
10
38
|
constructor(posts: Post[], tags: string[], options: SearchParameters, booru: Booru);
|
|
39
|
+
/**
|
|
40
|
+
* Get the first post in this result set
|
|
41
|
+
* @return {Post}
|
|
42
|
+
*/
|
|
11
43
|
get first(): Post;
|
|
44
|
+
/**
|
|
45
|
+
* Get the last post in this result set
|
|
46
|
+
* @return {Post}
|
|
47
|
+
*/
|
|
12
48
|
get last(): Post;
|
|
49
|
+
/**
|
|
50
|
+
* Get the next page
|
|
51
|
+
* <p>Works like <code>sb.search('cat', {page: 1}); sb.search('cat', {page: 2})</code>
|
|
52
|
+
* @return {Promise<SearchResults>}
|
|
53
|
+
*/
|
|
13
54
|
nextPage(): Promise<SearchResults>;
|
|
55
|
+
/**
|
|
56
|
+
* Create a new SearchResults with just images with the matching tags
|
|
57
|
+
*
|
|
58
|
+
* @param {String[]|String} tags The tags (or tag) to search for
|
|
59
|
+
* @param {Object} options The extra options for the search
|
|
60
|
+
* @param {Boolean} [options.invert=false] If the results should be inverted and
|
|
61
|
+
* return images *not* tagged
|
|
62
|
+
* @return {SearchResults}
|
|
63
|
+
*/
|
|
14
64
|
tagged(tags: string[] | string, { invert }?: {
|
|
15
65
|
invert?: boolean | undefined;
|
|
16
66
|
}): SearchResults;
|
|
67
|
+
/**
|
|
68
|
+
* Returns a SearchResults with images *not* tagged with any of the specified tags (or tag)
|
|
69
|
+
* @param {String[]|String} tags The tags (or tag) to blacklist
|
|
70
|
+
* @return {SearchResults} The results without any images with the specified tags
|
|
71
|
+
*/
|
|
17
72
|
blacklist(tags: string[] | string): SearchResults;
|
|
18
73
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchResults.js","sourceRoot":"","sources":["../../src/structures/SearchResults.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"SearchResults.js","sourceRoot":"","sources":["../../src/structures/SearchResults.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;AAIH,gDAAiC;AAGjC;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAqB,aAAc,SAAQ,KAAW;IACpD,qCAAqC;IAC9B,KAAK,CAAO;IACnB,8BAA8B;IACvB,IAAI,CAAQ;IACnB,oCAAoC;IACpB,IAAI,CAAU;IAC9B,uCAAuC;IACvB,OAAO,CAAkB;IACzC,wCAAwC;IACxB,KAAK,CAAQ;IAE7B,eAAe;IACf,YACE,KAAa,EACb,IAAc,EACd,OAAyB,EACzB,KAAY;QAEZ,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;QAEnB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACrC,IAAI,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;SACnB;QAED,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAC7C,CAAC;IAED;;;OAGG;IACH,IAAI,KAAK;QACP,O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;AAjGD,gCAiGC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* @module Structures
|
|
4
|
+
*/
|
|
5
|
+
import SiteApi from './SiteApi';
|
|
6
|
+
import SiteInfo from './SiteInfo';
|
|
7
|
+
/**
|
|
8
|
+
* Represents a site, mostly used for JSDoc
|
|
9
|
+
*/
|
|
10
|
+
export default class Site {
|
|
11
|
+
/** The domain of the Site (the "google.com" part of "https://google.com/foo") */
|
|
12
|
+
domain: string;
|
|
13
|
+
/** The type of this site (json/xml/derpi) */
|
|
14
|
+
type: string;
|
|
15
|
+
/** The aliases of this site */
|
|
16
|
+
aliases: string[];
|
|
17
|
+
/** If this site serves NSFW posts or not */
|
|
18
|
+
nsfw: boolean;
|
|
19
|
+
/** An object representing the api of this site */
|
|
20
|
+
api: SiteApi;
|
|
21
|
+
/** The url query param to paginate on the site */
|
|
22
|
+
paginate: string;
|
|
23
|
+
/**
|
|
24
|
+
* If the site supports `order:random`.
|
|
25
|
+
* If a string, this means a custom random system is used :/
|
|
26
|
+
*/
|
|
27
|
+
random: boolean | string;
|
|
28
|
+
/** The url query param for tags */
|
|
29
|
+
tagQuery: string;
|
|
30
|
+
/** If this site supports only http:// */
|
|
31
|
+
insecure: boolean;
|
|
32
|
+
/** Tags to add to every request, if not included */
|
|
33
|
+
defaultTags: string[];
|
|
34
|
+
constructor(data: SiteInfo);
|
|
35
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});class Site{domain;type;aliases;nsfw;api;paginate;random;tagQuery;insecure;defaultTags;constructor(a){this.domain=a.domain,this.type=a.type||"json",this.aliases=a.aliases||[],this.nsfw=a.nsfw,this.api=a.api||{},this.paginate=a.paginate||"page",this.random=a.random||!1,this.tagQuery=a.tagQuery||"tags",this.insecure=a.insecure||!1,this.defaultTags=a.defaultTags||[]}}exports.default=Site;
|
|
@@ -0,0 +1 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entation
|
|
3
|
+
* @module Structures
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Represents the api of a {@link Site}
|
|
7
|
+
* <p>Each property is a path on the {@link Site}
|
|
8
|
+
*/
|
|
9
|
+
export default interface SiteApi {
|
|
10
|
+
/** The path to search for posts */
|
|
11
|
+
search: string;
|
|
12
|
+
/** The path to view a post by ID */
|
|
13
|
+
postView: string;
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SiteApi.js","sourceRoot":"","sources":["../../src/structures/SiteApi.ts"],"names":[],"mappings":";AAAA;;;GAGG"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* @module Structures
|
|
4
|
+
*/
|
|
5
|
+
import SiteApi from './SiteApi';
|
|
6
|
+
/**
|
|
7
|
+
* Represents the info needed to create a new {@link Site}
|
|
8
|
+
* <p>Same properties as {@link Site}, but some optional</p>
|
|
9
|
+
* <p>Mostly just here to reflect what sites.json should look like
|
|
10
|
+
*/
|
|
11
|
+
export default interface SiteInfo {
|
|
12
|
+
/** The domain of the Site (the "google.com" part of "https://google.com/foo") */
|
|
13
|
+
domain: string;
|
|
14
|
+
/** The type of this site (json/xml/derpi) */
|
|
15
|
+
type: string;
|
|
16
|
+
/** The aliases of this site */
|
|
17
|
+
aliases: string[];
|
|
18
|
+
/** If this site serves NSFW posts or not */
|
|
19
|
+
nsfw: boolean;
|
|
20
|
+
/** An object representing the api of this site */
|
|
21
|
+
api: SiteApi;
|
|
22
|
+
/** The url query param to paginate on the site */
|
|
23
|
+
paginate?: string;
|
|
24
|
+
/** If the site supports `order:random` */
|
|
25
|
+
random: boolean | string;
|
|
26
|
+
/** The url query param for tags */
|
|
27
|
+
tagQuery?: string;
|
|
28
|
+
/** If this site supports only http:// */
|
|
29
|
+
insecure?: boolean;
|
|
30
|
+
/** Tags to add to every request, if not included */
|
|
31
|
+
defaultTags?: string[];
|
|
32
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SiteInfo.js","sourceRoot":"","sources":["../../src/structures/SiteInfo.ts"],"names":[],"mappings":";AAAA;;;GAGG"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "booru",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.3",
|
|
4
4
|
"description": "Search (and do other things) on a bunch of different boorus!",
|
|
5
5
|
"author": "AtoraSuunva (https://github.com/AtoraSuunva/)",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "./dist/index.js",
|
|
8
8
|
"typings": "./dist/index.d.ts",
|
|
9
|
-
"runkitExampleFilename": "./dist/example.js",
|
|
10
9
|
"homepage": "https://github.com/AtoraSuunva/booru#readme",
|
|
11
10
|
"repository": {
|
|
12
11
|
"type": "git",
|
|
@@ -16,12 +15,11 @@
|
|
|
16
15
|
"url": "https://github.com/AtoraSuunva/booru/issues"
|
|
17
16
|
},
|
|
18
17
|
"scripts": {
|
|
18
|
+
"file": "node --loader ts-node/esm",
|
|
19
19
|
"test": "jest",
|
|
20
20
|
"lint": "eslint -c .eslintrc.js --ext .ts ./src",
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"build": "tsc --sourceMap",
|
|
24
|
-
"build-dev": "tsc --sourceMap",
|
|
21
|
+
"prebuild": "npm run lint",
|
|
22
|
+
"build": "tsc",
|
|
25
23
|
"postbuild": "node ./minify.js",
|
|
26
24
|
"prepublishOnly": "npm run build"
|
|
27
25
|
},
|
|
@@ -52,6 +50,7 @@
|
|
|
52
50
|
"@babel/polyfill": "^7.12.1",
|
|
53
51
|
"@babel/preset-env": "^7.15.4",
|
|
54
52
|
"@babel/preset-typescript": "^7.15.0",
|
|
53
|
+
"@swc/core": "^1.2.128",
|
|
55
54
|
"@types/jest": "^27.0.1",
|
|
56
55
|
"@types/node": "^16.9.0",
|
|
57
56
|
"@types/node-fetch": "^2.5.12",
|
|
@@ -61,12 +60,10 @@
|
|
|
61
60
|
"eslint-config-prettier": "^8.3.0",
|
|
62
61
|
"eslint-plugin-import": "^2.24.2",
|
|
63
62
|
"eslint-plugin-jsdoc": "^36.1.0",
|
|
64
|
-
"eslint-plugin-no-null": "^1.0.2",
|
|
65
|
-
"eslint-plugin-prefer-arrow": "^1.2.3",
|
|
66
63
|
"jest": "^27.1.1",
|
|
67
64
|
"prettier": "^2.3.2",
|
|
68
|
-
"rimraf": "^3.0.2",
|
|
69
65
|
"terser": "^5.7.2",
|
|
66
|
+
"ts-node": "^10.4.0",
|
|
70
67
|
"typescript": "^4.4.2"
|
|
71
68
|
},
|
|
72
69
|
"files": [
|
package/dist/test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/test.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const index_1=require("./index");(0,index_1.search)("gb",["rating:s"],{limit:1}).then((e=>{console.log("Got post",e)})).catch((e=>{console.error(e)}));
|
package/dist/test.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"test.js","sourceRoot":"","sources":["../src/test.ts"],"names":[],"mappings":";;AAAA,mCAAgC;AAEhC,IAAA,cAAM,EAAC,IAAI,EAAE,CAAC,UAAU,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;KACrC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE;IACd,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,KAAK,CAAC,CAAA;AAChC,CAAC,CAAC;KACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACb,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;AACpB,CAAC,CAAC,CAAA"}
|