booru 2.5.9 → 2.6.0
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 +5 -5
- package/dist/Constants.js +1 -1
- package/dist/Constants.js.map +1 -1
- package/dist/Utils.d.ts +24 -1
- package/dist/Utils.js +1 -1
- package/dist/Utils.js.map +1 -1
- package/dist/boorus/Booru.d.ts +2 -4
- package/dist/boorus/Booru.js +1 -1
- package/dist/boorus/Booru.js.map +1 -1
- package/dist/index.d.ts +7 -4
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/structures/SearchParameters.d.ts +0 -3
- package/package.json +1 -1
package/dist/Constants.d.ts
CHANGED
|
@@ -3,15 +3,14 @@
|
|
|
3
3
|
* @module Constants
|
|
4
4
|
*/
|
|
5
5
|
import { RequestInit } from 'undici';
|
|
6
|
+
import { BooruCredentials } from './boorus/Booru';
|
|
6
7
|
import Site from './structures/Site';
|
|
7
8
|
import SiteInfo from './structures/SiteInfo';
|
|
8
|
-
export
|
|
9
|
-
[key: string]: V;
|
|
10
|
-
}
|
|
9
|
+
export declare type AnySite = 'e621.net' | 'e926.net' | 'hypnohub.net' | 'danbooru.donmai.us' | 'konachan.com' | 'konachan.net' | 'yande.re' | 'gelbooru.com' | 'rule34.xxx' | 'safebooru.org' | 'tbib.org' | 'xbooru.com' | 'rule34.paheal.net' | 'derpibooru.org' | 'realbooru.com';
|
|
11
10
|
/**
|
|
12
11
|
* A map of site url/{@link SiteInfo}
|
|
13
12
|
*/
|
|
14
|
-
export declare const sites:
|
|
13
|
+
export declare const sites: Record<AnySite, SiteInfo>;
|
|
15
14
|
/**
|
|
16
15
|
* Custom error type for when the boorus error or for user-side error, not my code (probably)
|
|
17
16
|
* <p>The name of the error is 'BooruError'
|
|
@@ -34,8 +33,9 @@ export declare const USER_AGENT = "booru (https://github.com/AtoraSuunva/booru)"
|
|
|
34
33
|
* @param {string[]} [tags=[]] The tags to search for
|
|
35
34
|
* @param {number} [limit=100] The limit for images to return
|
|
36
35
|
* @param {number} [page=0] The page to get
|
|
36
|
+
* @param {BooryCredentials} [credentials] The credentials to use for the search, appended to the querystring
|
|
37
37
|
*/
|
|
38
|
-
export declare function searchURI(site: Site, tags
|
|
38
|
+
export declare function searchURI(site: Site, tags?: string[], limit?: number, page?: number, credentials?: BooruCredentials): string;
|
|
39
39
|
/**
|
|
40
40
|
* The default options to use for requests
|
|
41
41
|
* <p>I could document this better but meh
|
package/dist/Constants.js
CHANGED
|
@@ -1 +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
|
|
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")),Utils_1=require("./Utils"),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 t=expandedTags[r.toLowerCase()];return encodeURIComponent(t||r)}))}function searchURI(r,t=[],e=100,o=0,s={}){const a=(0,Utils_1.querystring)({[r.tagQuery]:expandTags(t).join(r.tagJoin),limit:e,[r.paginate]:o,...s});return`http${r.insecure?"":"s"}://${r.domain}${r.api.search}`+a}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}};
|
package/dist/Constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Constants.js","sourceRoot":"","sources":["../src/Constants.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;
|
|
1
|
+
{"version":3,"file":"Constants.js","sourceRoot":"","sources":["../src/Constants.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAIH,8DAAmC;AAGnC,mCAAqC;AA2BrC,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;;;;;;;;;;GAUG;AACH,SAAgB,SAAS,CACvB,IAAU,EACV,OAAiB,EAAE,EACnB,KAAK,GAAG,GAAG,EACX,IAAI,GAAG,CAAC,EACR,cAAgC,EAAE;IAElC,MAAM,KAAK,GAAG,IAAA,mBAAW,EAAC;QACxB,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;QACpD,KAAK;QACL,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,IAAI;QACrB,GAAG,WAAW;KACf,CAAC,CAAA;IAEF,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,KAAK,CACN,CAAA;AACH,CAAC;AAnBD,8BAmBC;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
CHANGED
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
* @packageDocumentation
|
|
3
3
|
* @module Utils
|
|
4
4
|
*/
|
|
5
|
+
import { AnySite } from './Constants';
|
|
5
6
|
/**
|
|
6
7
|
* Check if `site` is a supported site (and check if it's an alias and return the sites's true name)
|
|
7
8
|
*
|
|
8
9
|
* @param {String} domain The site to resolveSite
|
|
9
10
|
* @return {String?} null if site is not supported, the site otherwise
|
|
10
11
|
*/
|
|
11
|
-
export declare function resolveSite(domain: string):
|
|
12
|
+
export declare function resolveSite(domain: string): AnySite | null;
|
|
12
13
|
/**
|
|
13
14
|
* Parses xml to json, which can be used with js
|
|
14
15
|
*
|
|
@@ -62,3 +63,25 @@ export declare function validateSearchParams(site: string, limit: number | strin
|
|
|
62
63
|
* @return {String[]} The shared strings between the arrays
|
|
63
64
|
*/
|
|
64
65
|
export declare function compareArrays(arr1: string[], arr2: string[]): string[];
|
|
66
|
+
declare type URIEncodable = string | number | boolean;
|
|
67
|
+
declare type QueryValue = URIEncodable | URIEncodable[];
|
|
68
|
+
/**
|
|
69
|
+
* Turns an object into a query string, correctly encoding uri components
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* const options = { page: 10, limit: 100 }
|
|
73
|
+
* const query = querystring(options) // 'page=10&limit=100'
|
|
74
|
+
* console.log(`https://example.com?${query}`)
|
|
75
|
+
*
|
|
76
|
+
* @param query An object with key/value pairs that will be turned into a string
|
|
77
|
+
* @returns A string that can be appended to a url (after `?`)
|
|
78
|
+
*/
|
|
79
|
+
export declare function querystring(query: Record<string, QueryValue>): string;
|
|
80
|
+
/**
|
|
81
|
+
* Encodes a single value or an array of values to be usable in as a URI component,
|
|
82
|
+
* joining array elements with '+'
|
|
83
|
+
* @param value The value to encode
|
|
84
|
+
* @returns An encoded value that can be passed to a querystring
|
|
85
|
+
*/
|
|
86
|
+
export declare function encodeURIQueryValue(value: QueryValue): string;
|
|
87
|
+
export {};
|
package/dist/Utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.compareArrays=exports.validateSearchParams=exports.randInt=exports.shuffle=exports.tryParseJSON=exports.jsonfy=exports.resolveSite=void 0;const Constants_1=require("./Constants"),fast_xml_parser_1=require("fast-xml-parser");function resolveSite(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.encodeURIQueryValue=exports.querystring=exports.compareArrays=exports.validateSearchParams=exports.randInt=exports.shuffle=exports.tryParseJSON=exports.jsonfy=exports.resolveSite=void 0;const Constants_1=require("./Constants"),fast_xml_parser_1=require("fast-xml-parser");function resolveSite(e){if("string"!=typeof e)return null;e=e.toLowerCase();for(const[r,t]of Object.entries(Constants_1.sites))if(r===e||t.domain===e||t.aliases.includes(e))return r;return null}exports.resolveSite=resolveSite;const xmlParser=new fast_xml_parser_1.XMLParser({ignoreAttributes:!1,attributeNamePrefix:""});function jsonfy(e){if("object"==typeof e)return e;const r=xmlParser.parse(e);if(r.html||r["!doctype"]){const e=r.html||r["!doctype"]?.html,t=[];throw e.body.h1&&t.push(e.body.h1),e.body.p&&t.push(e.body.p["#text"]),new Constants_1.BooruError(`The Booru sent back an error: '${t.join(": ")}'`)}return r.posts.post?r.posts.post:r.posts.tag?Array.isArray(r.posts.tag)?r.posts.tag:[r.posts.tag]:[]}function tryParseJSON(e){return""===e?[]:JSON.parse(e)}function shuffle(e){let r,t,o=e.length;for(;0!==o;)t=Math.floor(Math.random()*o),o-=1,r=e[o],e[o]=e[t],e[t]=r;return e}function randInt(e,r){return e=Math.ceil(e),r=Math.floor(r),Math.floor(Math.random()*(r-e+1))+e}function validateSearchParams(e,r){const t=resolveSite(e);if("number"!=typeof r&&(r=parseInt(r,10)),null===t)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:t,limit:r}}function compareArrays(e,r){return e.filter((e=>r.some((r=>e.toLowerCase()===r.toLowerCase()))))}function querystring(e){return Object.entries(e).map((([e,r])=>`${encodeURIComponent(e)}=${encodeURIQueryValue(r)}`)).join("&")}function encodeURIQueryValue(e){return Array.isArray(e)?e.map(encodeURIComponent).join("+"):encodeURIComponent(e)}exports.jsonfy=jsonfy,exports.tryParseJSON=tryParseJSON,exports.shuffle=shuffle,exports.randInt=randInt,exports.validateSearchParams=validateSearchParams,exports.compareArrays=compareArrays,exports.querystring=querystring,exports.encodeURIQueryValue=encodeURIQueryValue;
|
package/dist/Utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Utils.js","sourceRoot":"","sources":["../src/Utils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,
|
|
1
|
+
{"version":3,"file":"Utils.js","sourceRoot":"","sources":["../src/Utils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2CAAwD;AAExD,qDAA2C;AAE3C;;;;;GAKG;AACH,SAAgB,WAAW,CAAC,MAAc;IACxC,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;QAC9B,OAAO,IAAI,CAAA;KACZ;IAED,MAAM,GAAG,MAAM,CAAC,WAAW,EAAE,CAAA;IAE7B,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,iBAAK,CAAC,EAAE;QAChD,IACE,IAAI,KAAK,MAAM;YACf,IAAI,CAAC,MAAM,KAAK,MAAM;YACtB,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,EAC7B;YACA,OAAO,IAAe,CAAA;SACvB;KACF;IAED,OAAO,IAAI,CAAA;AACb,CAAC;AAlBD,kCAkBC;AAiBD,MAAM,SAAS,GAAG,IAAI,2BAAS,CAAC;IAC9B,gBAAgB,EAAE,KAAK;IACvB,mBAAmB,EAAE,EAAE;CACxB,CAAC,CAAA;AAEF;;;;;;GAMG;AACH,SAAgB,MAAM,CAAC,GAAW;IAChC,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,GAAG,CAAA;IAEvC,MAAM,IAAI,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAa,CAAA;IAE7C,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,UAAU,CAAC,EAAE;QACjC,0EAA0E;QAC1E,+CAA+C;QAC/C,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,UAAU,CAAC,EAAE,IAAI,CAAA;Q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AAc;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;AAKD;;;;;;;;;;GAUG;AACH,SAAgB,WAAW,CAAC,KAAiC;IAC3D,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;SACzB,GAAG,CACF,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CACf,GAAG,kBAAkB,CAAC,GAAG,CAAC,IAAI,mBAAmB,CAAC,KAAK,CAAC,EAAE,CAC7D;SACA,IAAI,CAAC,GAAG,CAAC,CAAA;AACd,CAAC;AAPD,kCAOC;AAED;;;;;GAKG;AACH,SAAgB,mBAAmB,CAAC,KAAiB;IACnD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACxB,OAAO,KAAK,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;KAC/C;SAAM;QACL,OAAO,kBAAkB,CAAC,KAAK,CAAC,CAAA;KACjC;AACH,CAAC;AAND,kDAMC"}
|
package/dist/boorus/Booru.d.ts
CHANGED
|
@@ -6,9 +6,7 @@ import InternalSearchParameters from '../structures/InternalSearchParameters';
|
|
|
6
6
|
import SearchParameters from '../structures/SearchParameters';
|
|
7
7
|
import SearchResults from '../structures/SearchResults';
|
|
8
8
|
import Site from '../structures/Site';
|
|
9
|
-
export
|
|
10
|
-
token: string;
|
|
11
|
-
}
|
|
9
|
+
export declare type BooruCredentials = Record<string, string>;
|
|
12
10
|
interface SearchUrlParams {
|
|
13
11
|
tags: string[];
|
|
14
12
|
limit: number;
|
|
@@ -78,7 +76,7 @@ export declare class Booru {
|
|
|
78
76
|
* @param {number} [opt.page] The page of results to return
|
|
79
77
|
* @returns A URL to search the booru
|
|
80
78
|
*/
|
|
81
|
-
getSearchUrl({ tags, limit, page, }
|
|
79
|
+
getSearchUrl({ tags, limit, page, }?: Partial<SearchUrlParams>): string;
|
|
82
80
|
/**
|
|
83
81
|
* Parse the response from the booru
|
|
84
82
|
*
|
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 undici_1=require("undici"),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):undici_1.fetch;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=await t.text(),s=l?(0,Utils_1.jsonfy)(e):(0,Utils_1.tryParseJSON)(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;
|
|
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 undici_1=require("undici"),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):undici_1.fetch;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=await t.text(),s=l?(0,Utils_1.jsonfy)(e):(0,Utils_1.tryParseJSON)(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,this.credentials)}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/Booru.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,mCAA8B;AAC9B,4CAAoE;AACpE,oCAAqE;AAGrE,8DAAqC;AAErC,gFAAuD;AAOvD,MAAM,aAAa,GACjB,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,cAAK,CAAA;
|
|
1
|
+
{"version":3,"file":"Booru.js","sourceRoot":"","sources":["../../src/boorus/Booru.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,mCAA8B;AAC9B,4CAAoE;AACpE,oCAAqE;AAGrE,8DAAqC;AAErC,gFAAuD;AAOvD,MAAM,aAAa,GACjB,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,cAAK,CAAA;AAUnE;;;;;;GAMG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAa,KAAK;IAChB,8BAA8B;IACvB,MAAM,CAAQ;IACrB,8CAA8C;IACvC,IAAI,CAAM;IACjB,4CAA4C;IACrC,WAAW,CAAmB;IAErC;;;;;;OAMG;IACH,YAAY,IAAU,EAAE,WAA8B;QACpD,MAAM,MAAM,GAAG,IAAA,mBAAW,EAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QAEvC,IAAI,MAAM,KAAK,IAAI,EAAE;YACnB,MAAM,IAAI,KAAK,CAAC,wBAAwB,IAAI,EAAE,CAAC,CAAA;SAChD;QAED,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;IAChC,CAAC;IAED;;;;;O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xB,IAAI,GAAG,CAAC,IAAI,CAAC,CAAA;SACd;QAED,IAAI,CAAC,eAAe,EAAE;YACpB,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;SACzC;QAED,OAAO,IAAI,uBAAa,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,CAAA;IACtD,CAAC;CACF;AAxPD,sBAwPC;AAED,kBAAe,KAAK,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @packageDocumentation
|
|
3
3
|
* @module Index
|
|
4
4
|
*/
|
|
5
|
-
import Booru from './boorus/Booru';
|
|
5
|
+
import Booru, { BooruCredentials } from './boorus/Booru';
|
|
6
6
|
import Post from './structures/Post';
|
|
7
7
|
import SearchParameters from './structures/SearchParameters';
|
|
8
8
|
import SearchResults from './structures/SearchResults';
|
|
@@ -11,12 +11,15 @@ import SearchResults from './structures/SearchResults';
|
|
|
11
11
|
*
|
|
12
12
|
* @constructor
|
|
13
13
|
* @param {String} site The {@link Site} domain (or alias of it) to create a booru from
|
|
14
|
-
* @param {
|
|
14
|
+
* @param {BooruCredentials} credentials The credentials to use on this booru
|
|
15
15
|
* @return {Booru} A booru to use
|
|
16
16
|
*/
|
|
17
|
-
declare function booruForSite(site: string, credentials?:
|
|
17
|
+
declare function booruForSite(site: string, credentials?: BooruCredentials): Booru;
|
|
18
18
|
export { booruForSite as forSite };
|
|
19
19
|
export default booruForSite;
|
|
20
|
+
export interface BooruSearch extends SearchParameters {
|
|
21
|
+
credentials?: BooruCredentials;
|
|
22
|
+
}
|
|
20
23
|
/**
|
|
21
24
|
* Searches a site for images with tags and returns the results
|
|
22
25
|
* @param {String} site The site to search
|
|
@@ -32,7 +35,7 @@ export default booruForSite;
|
|
|
32
35
|
* Booru.search('e926', ['glaceon', 'cute'])
|
|
33
36
|
* ```
|
|
34
37
|
*/
|
|
35
|
-
export declare function search(site: string, tags?: string[] | string, { limit, random, page, credentials }?:
|
|
38
|
+
export declare function search(site: string, tags?: string[] | string, { limit, random, page, credentials }?: BooruSearch): Promise<SearchResults>;
|
|
36
39
|
/**
|
|
37
40
|
* Deprecated, now a noop
|
|
38
41
|
* <p>This will be removed *soon* please stop using it</p>
|
package/dist/index.js
CHANGED
|
@@ -1 +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.BooruError=exports.resolveSite=exports.sites=exports.BooruClass=exports.commonfy=exports.search=exports.forSite=void 0;const Constants_1=require("./Constants"),util_1=require("util"),Booru_1=__importDefault(require("./boorus/Booru")),Derpibooru_1=__importDefault(require("./boorus/Derpibooru")),XmlBooru_1=__importDefault(require("./boorus/XmlBooru")),Site_1=__importDefault(require("./structures/Site")),Utils_1=require("./Utils"),BooruTypes={derpi:Derpibooru_1.default,xml:XmlBooru_1.default},booruCache={};function booruFrom(r,e){return new(void 0!==r.type&&BooruTypes[r.type]?BooruTypes[r.type]:Booru_1.default)(r,e)}function booruForSite(r,e
|
|
1
|
+
"use strict";var __importDefault=this&&this.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.BooruError=exports.resolveSite=exports.sites=exports.BooruClass=exports.commonfy=exports.search=exports.forSite=void 0;const Constants_1=require("./Constants"),util_1=require("util"),Booru_1=__importDefault(require("./boorus/Booru")),Derpibooru_1=__importDefault(require("./boorus/Derpibooru")),XmlBooru_1=__importDefault(require("./boorus/XmlBooru")),Site_1=__importDefault(require("./structures/Site")),Utils_1=require("./Utils"),BooruTypes={derpi:Derpibooru_1.default,xml:XmlBooru_1.default},booruCache={};function booruFrom(r,e){return new(void 0!==r.type&&BooruTypes[r.type]?BooruTypes[r.type]:Booru_1.default)(r,e)}function booruForSite(r,e){const o=(0,Utils_1.resolveSite)(r);if(!o)throw new Constants_1.BooruError("Site not supported");return booruFrom(new Site_1.default(Constants_1.sites[o]),e)}function search(r,e=[],{limit:o=1,random:t=!1,page:s=0,credentials:u={}}={}){const n=(0,Utils_1.resolveSite)(r);if("string"==typeof o&&(o=parseInt(o,10)),null===n)throw new Constants_1.BooruError("Site not supported");if(!Array.isArray(e)&&"string"!=typeof e)throw new Constants_1.BooruError("`tags` should be an array or string");if("number"!=typeof o||Number.isNaN(o))throw new Constants_1.BooruError("`limit` should be an int");const i=new Site_1.default(Constants_1.sites[n]);return booruCache[n]||(booruCache[n]=booruFrom(i,u)),booruCache[n].credentials=u,booruCache[n].search(e,{limit:o,random:t,page:s})}exports.forSite=booruForSite,exports.default=booruForSite,exports.search=search;const deprecatedCommonfy=(0,util_1.deprecate)((()=>{}),"Common is now deprecated, just access the properties directly");function commonfy(r){return deprecatedCommonfy(),Promise.resolve(r)}exports.commonfy=commonfy;var Booru_2=require("./boorus/Booru");Object.defineProperty(exports,"BooruClass",{enumerable:!0,get:function(){return Booru_2.Booru}});var Constants_2=require("./Constants");Object.defineProperty(exports,"sites",{enumerable:!0,get:function(){return Constants_2.sites}});var Utils_2=require("./Utils");Object.defineProperty(exports,"resolveSite",{enumerable:!0,get:function(){return Utils_2.resolveSite}});var Constants_3=require("./Constants");Object.defineProperty(exports,"BooruError",{enumerable:!0,get:function(){return Constants_3.BooruError}});
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,2CAAwD;AAExD,+BAAgC;AAChC,2DAAwD;AACxD,qEAA4C;AAC5C,iEAAwC;AAIxC,6DAAoC;AACpC,mCAAqC;AAErC,MAAM,UAAU,GAAiC;IAC/C,KAAK,EAAE,oB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
|
|
4
4
|
*/
|
|
5
|
-
import { BooruCredentials } from '../boorus/Booru';
|
|
6
5
|
/**
|
|
7
6
|
* Just an interface for {@link Booru}'s search params :)
|
|
8
7
|
*/
|
|
@@ -13,8 +12,6 @@ export default interface SearchParameters {
|
|
|
13
12
|
random?: boolean;
|
|
14
13
|
/** Which page of results to fetch */
|
|
15
14
|
page?: number;
|
|
16
|
-
/** The credentials to use to auth with the booru */
|
|
17
|
-
credentials?: BooruCredentials;
|
|
18
15
|
/** Return unavailable posts (ie. banned/deleted posts) */
|
|
19
16
|
showUnavailable?: boolean;
|
|
20
17
|
}
|