booru 2.3.3 → 2.4.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/LICENSE.md CHANGED
@@ -1,25 +1,25 @@
1
- The MIT License (MIT)
2
- =====================
3
-
4
- Copyright © `2020` `D. "AtlasTheBot" Plaza`
5
-
6
- Permission is hereby granted, free of charge, to any person
7
- obtaining a copy of this software and associated documentation
8
- files (the “Software”), to deal in the Software without
9
- restriction, including without limitation the rights to use,
10
- copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- copies of the Software, and to permit persons to whom the
12
- Software is furnished to do so, subject to the following
13
- conditions:
14
-
15
- The above copyright notice and this permission notice shall be
16
- included in all copies or substantial portions of the Software.
17
-
18
- THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
19
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20
- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22
- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25
- OTHER DEALINGS IN THE SOFTWARE.
1
+ The MIT License (MIT)
2
+ =====================
3
+
4
+ Copyright © `2020` `D. "AtlasTheBot" Plaza`
5
+
6
+ Permission is hereby granted, free of charge, to any person
7
+ obtaining a copy of this software and associated documentation
8
+ files (the “Software”), to deal in the Software without
9
+ restriction, including without limitation the rights to use,
10
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the
12
+ Software is furnished to do so, subject to the following
13
+ conditions:
14
+
15
+ The above copyright notice and this permission notice shall be
16
+ included in all copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
19
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25
+ OTHER DEALINGS IN THE SOFTWARE.
@@ -6,8 +6,8 @@ export interface SMap<V> {
6
6
  }
7
7
  export declare const sites: SMap<SiteInfo>;
8
8
  export declare class BooruError extends Error {
9
- constructor(...args: any);
9
+ constructor(message: string | Error);
10
10
  }
11
- export declare const userAgent: string;
11
+ export declare const USER_AGENT = "booru (https://github.com/AtoraSuunva/booru)";
12
12
  export declare function searchURI(site: Site, tags: string[] | undefined, limit: number | undefined, page: number): string;
13
13
  export declare const defaultOptions: RequestInit;
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.userAgent=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[0]instanceof Error?[r[0].message]:r),r[0]instanceof Error?this.stack=r[0].stack:Error.captureStackTrace(this,BooruError),this.name="BooruError"}}function expandTags(r){return r.map((r=>{const e=expandedTags[r.toLowerCase()];return encodeURI(e||r)}))}function searchURI(r,e=[],t=100,s){return`http${r.insecure?"":"s"}://${r.domain}${r.api.search}${r.tagQuery}=${expandTags(e).join("+")}&limit=${t}&${r.paginate}=${s}`}exports.BooruError=BooruError,exports.userAgent="booru (https://github.com/AtlasTheBot/booru)",exports.searchURI=searchURI,exports.defaultOptions={headers:{Accept:"application/json, application/xml;q=0.9, */*;q=0.8","User-Agent":exports.userAgent}};
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 encodeURI(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":";;;;;;AAMA,8DAAmC;AAgBnC,MAAM,YAAY,GAAY;IAC5B,UAAU,EAAE,iBAAiB;IAC7B,UAAU,EAAE,qBAAqB;IACjC,UAAU,EAAE,aAAa;CAC1B,CAAA;AAKY,QAAA,KAAK,GAAG,oBAAqC,CAAA;AAO1D,MAAa,UAAW,SAAQ,KAAK;IACnC,YAAY,OAAuB;QACjC,KAAK,CAAC,OAAO,YAAY,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAA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onfy(xml: string): Promise<object[]>;
2
+ export declare function jsonfy(xml: string): object[];
3
3
  export declare function shuffle<T>(array: T[]): T[];
4
4
  export declare function randInt(min: number, max: number): number;
5
5
  export declare function validateSearchParams(site: string, limit: number | string): {
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.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].aliases.includes(t))return r;return null}async function jsonfy(t){if("object"==typeof t)return t;const r=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(": ")}'`,r.html)}return r.posts.post?r.posts.post:[]}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;
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":";;;AAKA,2CAA+C;AAE/C,qDAAmD;AAQnD,SAAgB,WAAW,CAAC,MAAc;IACxC,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;QAC9B,OAAO,IAAI,CAAA;KACZ;IAED,MAAM,GAAG,MAAM,CAAC,WAAW,EAAE,CAAA;I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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;AAUD,SAAgB,aAAa,CAAC,IAAc,EAAE,IAAc;IAC1D,OAAO,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CACtB,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,WAAW,EAAE,KAAK,EAAE,CAAC,WAAW,EAAE,CAAC,CACvD,CAAA;AACH,CAAC;AAJD,sCAIC"}
@@ -2,14 +2,23 @@
2
2
  import SearchParameters from '../structures/SearchParameters';
3
3
  import SearchResults from '../structures/SearchResults';
4
4
  import Site from '../structures/Site';
5
+ export interface BooruCredentials {
6
+ token: string;
7
+ }
8
+ interface SearchUrlParams {
9
+ tags: string[];
10
+ limit: number;
11
+ page: number;
12
+ }
5
13
  export declare class Booru {
6
14
  domain: string;
7
15
  site: Site;
8
- credentials: any;
9
- constructor(site: Site, credentials?: object | null);
10
- search(tags: string | string[], { limit, random, page, showUnavailable }?: SearchParameters): Promise<SearchResults>;
16
+ credentials?: BooruCredentials;
17
+ constructor(site: Site, credentials?: BooruCredentials);
18
+ search(tags: string | string[], { limit, random, page, showUnavailable, }?: SearchParameters): Promise<SearchResults>;
11
19
  postView(id: string | number): string;
12
20
  protected doSearchRequest(tags: string[] | string, { uri, limit, random, page, }?: InternalSearchParameters): Promise<any>;
21
+ getSearchUrl({ tags, limit, page, }: Partial<SearchUrlParams>): string;
13
22
  protected parseSearchResult(result: any, { fakeLimit, tags, limit, random, page, showUnavailable, }: InternalSearchParameters): SearchResults;
14
23
  }
15
24
  export default Booru;
@@ -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{constructor(t,e=null){const s=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 new Constants_1.BooruError(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||Constants_1.searchURI(this.site,t,o||s,i),n=Constants_1.defaultOptions,l="xml"===this.site.type;try{const t=await resolvedFetch(a,n),e=l?await t.text():await t.json(),s=l?await 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}}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.posts&&(t=t.posts),t.images&&(t=t.images),""===t?n=[]:e?n=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 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){if((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.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;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Booru.js","sourceRoot":"","sources":["../../src/boorus/Booru.ts"],"names":[],"mappings":";;;;;;AAKA,4DAA8C;AAC9C,4CAAoE;AACpE,oCAAuD;AAGvD,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,oBAAK,CAAA;AAuCnE,MAAa,KAAK;IAET,MAAM,CAAQ;IAEd,IAAI,CAAM;IAEV,WAAW,CAAmB;IASrC,YAAY,IAAU,EAAE,WAA8B;QACpD,MAAM,MAAM,GAAG,IAAA,mBAAW,EAAC,IAAI,CAAC,MAAM,CAAC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AAzOD,sBAyOC;AAED,kBAAe,KAAK,CAAA"}
@@ -1,8 +1,8 @@
1
1
  import SearchParameters from '../structures/SearchParameters';
2
2
  import SearchResults from '../structures/SearchResults';
3
3
  import Site from '../structures/Site';
4
- import Booru from './Booru';
4
+ import Booru, { BooruCredentials } from './Booru';
5
5
  export default class Derpibooru extends Booru {
6
- constructor(site: Site, credentials?: any);
6
+ constructor(site: Site, credentials?: BooruCredentials);
7
7
  search(tags: string[] | string, { limit, random, page }?: SearchParameters): Promise<SearchResults>;
8
8
  }
@@ -1 +1 @@
1
- "use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});const Constants_1=require("../Constants"),Booru_1=__importDefault(require("./Booru"));class Derpibooru extends Booru_1.default{constructor(e,r){super(e,r)}search(e,{limit:r=1,random:t=!1,page:s=0}={}){Array.isArray(e)||(e=[e]),void 0===e[0]&&(e[0]="*"),s+=1;const o=Constants_1.searchURI(this.site,e,r,s)+(t?"&"+this.site.random:"")+(this.credentials?"&key="+this.credentials:"");return super.doSearchRequest(e,{limit:r,random:t,page:s,uri:o}).then((o=>super.parseSearchResult(o,{fakeLimit:0,tags:e,limit:r,random:t,page:s}))).catch((e=>Promise.reject(new Constants_1.BooruError(e))))}}exports.default=Derpibooru;
1
+ "use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});const Constants_1=require("../Constants"),Booru_1=__importDefault(require("./Booru"));class Derpibooru extends Booru_1.default{constructor(e,t){super(e,t)}search(e,{limit:t=1,random:r=!1,page:s=0}={}){Array.isArray(e)||(e=[e]),void 0===e[0]&&(e[0]="*"),s+=1;const o=this.getSearchUrl({tags:e,limit:t,page:s})+(r&&"string"===this.site.random?`&${this.site.random}`:"")+(this.credentials?`&key=${this.credentials.token}`:"");return super.doSearchRequest(e,{limit:t,random:r,page:s,uri:o}).then((o=>super.parseSearchResult(o,{fakeLimit:0,tags:e,limit:t,random:r,page:s}))).catch((e=>Promise.reject(new Constants_1.BooruError(e))))}}exports.default=Derpibooru;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Derpibooru.js","sourceRoot":"","sources":["../../src/boorus/Derpibooru.ts"],"names":[],"mappings":";;;;;AAKA,4CAAyC;AAIzC,oDAAiD;AASjD,MAAqB,UAAW,SAAQ,eAAK;IAM3C,YAAY,IAAU,EAAE,WAA8B;QACpD,KAAK,CAAC,IAAI,EAAE,WAAW,CAAC,CAAA;IAC1B,CAAC;IAGM,MAAM,CACX,IAAuB,EACvB,EAAE,KAAK,GAAG,CAAC,EAAE,MAAM,GAAG,KAAK,EAAE,IAAI,GAAG,CAAC,KAAuB,EAAE;QAE9D,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YACxB,IAAI,GAAG,CAAC,IAAI,CAAC,CAAA;SACd;QAGD,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE;YACzB,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,CAAA;SACd;QAGD,IAAI,IAAI,CAAC,CAAA;QAET,MAAM,GAAG,GACP,IAAI,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;YACxC,CAAC,MAAM,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACvE,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA;QAE5D,OAAO,KAAK;aACT,eAAe,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC;aACnD,IAAI,CAAC,CAAC,CAAC,EAAE,CACR,KAAK,CAAC,iBAAiB,CAAC,CAAC,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CACxE;aACA,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,sBAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAClD,CAAC;CACF;AAvCD,6BAuCC"}
@@ -1,5 +1,5 @@
1
1
  import Site from '../structures/Site';
2
- import Booru from './Booru';
2
+ import Booru, { BooruCredentials } from './Booru';
3
3
  export default class XmlBooru extends Booru {
4
- constructor(site: Site, credentials?: any);
4
+ constructor(site: Site, credentials?: BooruCredentials);
5
5
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"XmlBooru.js","sourceRoot":"","sources":["../../src/boorus/XmlBooru.ts"],"names":[],"mappings":";;;;;AAMA,oDAAiD;AAQjD,MAAqB,QAAS,SAAQ,eAAK;IAMzC,YAAY,IAAU,EAAE,WAA8B;QACpD,KAAK,CAAC,IAAI,EAAE,WAAW,CAAC,CAAA;IAC1B,CAAC;CACF;AATD,2BASC"}
package/dist/index.d.ts CHANGED
@@ -5,7 +5,7 @@ import SearchResults from './structures/SearchResults';
5
5
  declare function booruForSite(site: string, credentials?: any): Booru;
6
6
  export { booruForSite as forSite };
7
7
  export default booruForSite;
8
- export declare function search(site: string, tags?: string[] | string, { limit, random, page, credentials, showUnavailable, }?: SearchParameters): Promise<SearchResults>;
8
+ export declare function search(site: string, tags?: string[] | string, { limit, random, page, credentials }?: SearchParameters): Promise<SearchResults>;
9
9
  export declare function commonfy(images: Post[]): Promise<Post[]>;
10
10
  export { Booru as BooruClass } from './boorus/Booru';
11
11
  export { sites } from './Constants';
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=null){const o=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=null,showUnavailable:n=!1}={}){const i=Utils_1.resolveSite(r);if("string"==typeof o&&(o=parseInt(o,10)),null===i)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 a=new Site_1.default(Constants_1.sites[i]);return booruCache[i]||(booruCache[i]=booruFrom(a)),booruCache[i].search(e,{limit:o,random:t,page:s,credentials:u})}exports.forSite=booruForSite,exports.default=booruForSite,exports.search=search;const deprecatedCommonfy=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}});
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=null){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)),booruCache[n].search(e,{limit:o,random:t,page:s,credentials:u})}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}});
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAKA,2CAAqD;AAErD,+BAAgC;AAChC,2DAAwD;AACxD,qEAA4C;AAC5C,iEAAwC;AAIxC,6DAAoC;AACpC,mCAAqC;AAErC,MAAM,UAAU,GAAiC;IAC/C,KAAK,EAAE,oBAAU;IACjB,GAAG,EAAE,kBAAQ;CACd,CAAA;AAED,MAAM,UAAU,GAAgB,EAAE,CAAA;AASlC,SAAS,SAAS,CAAC,SAAe,EAAE,WAA8B;IAChE,OAAO,IAAI,CACT,SAAS,CAAC,IAAI,KAAK,SAAS,IAAI,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC;QACxD,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC;QAC5B,CAAC,CAAC,eAAK,CACV,CAAC,SAAS,EAAE,WAAW,CAAC,CAAA;AAC3B,CAAC;AAUD,SAAS,YAAY,CAAC,IAAY,EAAE,cAAmB,IAAI;IACzD,MAAM,KAAK,GAAG,IAAA,mBAAW,EAAC,IAAI,CAAC,CAAA;IAE/B,IAAI,CAAC,KAAK;QAAE,MAAM,IAAI,sBAAU,CAAC,oBAAoB,CAAC,CAAA;IAEtD,MAAM,SAAS,GAAG,IAAI,cAAI,CAAC,iBAAK,CAAC,KAAK,CAAC,CAAC,CAAA;IAGxC,OAAO,SAAS,CAAC,SAAS,EAAE,WAAW,CAAC,CAAA;AAC1C,CAAC;AAEwB,+BAAO;AAChC,kBAAe,YAAY,CAAA;AAiB3B,SAAgB,MAAM,CACpB,IAAY,EACZ,OAA0B,EAAE,EAC5B,EAAE,KAAK,GAAG,CAAC,EAAE,MAAM,GAAG,KAAK,EAAE,IAAI,GAAG,CAAC,EAAE,WAAW,KAAuB,EAAE;IAE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AAA;AACd,iCAAqC;AAA5B,oGAAA,WAAW,OAAA;AACpB,yCAAwC;AAA/B,uGAAA,UAAU,OAAA"}
package/dist/sites.json CHANGED
@@ -1 +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":"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"},"furry.booru.org":{"domain":"furry.booru.org","aliases":["fb","furrybooru"],"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},"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
+ {"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}}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InternalSearchParameters.js","sourceRoot":"","sources":["../../src/structures/InternalSearchParameters.ts"],"names":[],"mappings":""}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const util_1=require("util"),common=util_1.deprecate((()=>{}),"Common is now deprecated, just access the properties directly");function parseImageUrl(e,t,i){return!e||""===e.trim()||t.is_deleted?null:(e.startsWith("/data")&&(e="https://danbooru.donmai.us"+e),e.startsWith("/cached")&&(e="https://danbooru.donmai.us"+e),e.startsWith("/_images")&&(e="https://dollbooru.org"+e),e.startsWith("//derpicdn.net")&&(e="https:"+t.image),!t.file_url&&t.directory&&(e=`//${i.domain}/images/${t.directory}/${t.image}`),e.startsWith("http")||(e="https:"+e),encodeURI(e))}function getTags(e){let t=[];return Array.isArray(e.tags)?e.tags:(t=e.tags&&e.tags.general?Object.values(e.tags).reduce(((e,t)=>e.concat(t)),[]):e.tags?e.tags.split(" "):e.tag_string.split(" ").map((e=>e.replace(/,/g,"").replace(/ /g,"_"))),t.filter((e=>""!==e)))}class Post{constructor(e,t){this.data=e,this.booru=t;const i=e.is_deleted||e.is_banned;this.fileUrl=parseImageUrl(e.file_url||e.image||(i?e.source:void 0)||e.file&&e.file.url||e.representations&&e.representations.full,e,t),this.available=!i&&null!==this.fileUrl,this.height=parseInt(e.height||e.image_height||e.file&&e.file.height,10),this.width=parseInt(e.width||e.image_width||e.file&&e.file.width,10),this.sampleUrl=parseImageUrl(e.sample_url||e.large_file_url||e.representations&&e.representations.large||e.sample&&e.sample.url,e,t),this.sampleHeight=parseInt(e.sample_height||e.sample&&e.sample.height,10),this.sampleWidth=parseInt(e.sample_width||e.sample&&e.sample.width,10),this.previewUrl=parseImageUrl(e.preview_url||e.preview_file_url||e.representations&&e.representations.small||e.preview&&e.preview.url,e,t),this.previewHeight=parseInt(e.preview_height||e.preview&&e.preview.height,10),this.previewWidth=parseInt(e.preview_width||e.preview&&e.preview.width,10),this.id=e.id?e.id.toString():"No ID available",this.tags=getTags(e),e.score&&e.score.total?this.score=e.score.total:this.score=e.score?parseInt(e.score,10):e.score,this.source=e.source||e.sources||e.source_url,this.rating=e.rating||/(safe|suggestive|questionable|explicit)/i.exec(e.tags)||"u",Array.isArray(this.rating)&&(this.rating=this.rating[0]),"suggestive"===this.rating&&(this.rating="q"),this.rating=this.rating.charAt(0),this.createdAt=null,"object"==typeof e.created_at?this.createdAt=new Date(1e3*e.created_at.s+e.created_at.n/1e9):"number"==typeof e.created_at?this.createdAt=new Date(1e3*e.created_at):"number"==typeof e.change?this.createdAt=new Date(1e3*e.change):this.createdAt=new Date(e.created_at||e.date)}get file_url(){return this.fileUrl}get sample_url(){return this.sampleUrl}get sample_height(){return this.sampleHeight}get sample_width(){return this.sampleWidth}get preview_url(){return this.previewUrl}get preview_height(){return this.previewHeight}get preview_width(){return this.previewWidth}get postView(){return this.booru.postView(this.id)}get common(){return common(),this}}exports.default=Post;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const util_1=require("util"),common=(0,util_1.deprecate)((()=>{}),"Common is now deprecated, just access the properties directly");function parseImageUrl(e,t,i){return!e||""===e.trim()||t.is_deleted?null:(e.startsWith("/data")&&(e=`https://danbooru.donmai.us${e}`),e.startsWith("/cached")&&(e=`https://danbooru.donmai.us${e}`),e.startsWith("/_images")&&(e=`https://dollbooru.org${e}`),e.startsWith("//derpicdn.net")&&(e=`https:${t.image}`),!t.file_url&&t.directory&&(e=`//${i.domain}/images/${t.directory}/${t.image}`),e.startsWith("http")||(e=`https:${e}`),encodeURI(e))}function getTags(e){let t=[];return Array.isArray(e.tags)?e.tags:(t=e.tags&&e.tags.general?Object.values(e.tags).reduce(((e,t)=>e.concat(t)),[]):e.tags?e.tags.split(" "):e.tag_string.split(" ").map((e=>e.replace(/,/g,"").replace(/ /g,"_"))),t.filter((e=>""!==e)))}class Post{booru;fileUrl;height;width;sampleUrl;sampleHeight;sampleWidth;previewUrl;previewHeight;previewWidth;id;available;tags;score;source;rating;createdAt;data;constructor(e,t){this.data=e,this.booru=t;const i=e.is_deleted||e.is_banned;this.fileUrl=parseImageUrl(e.file_url||e.image||(i?e.source:void 0)||e.file&&e.file.url||e.representations&&e.representations.full,e,t),this.available=!i&&null!==this.fileUrl,this.height=parseInt(e.height||e.image_height||e.file&&e.file.height,10),this.width=parseInt(e.width||e.image_width||e.file&&e.file.width,10),this.sampleUrl=parseImageUrl(e.sample_url||e.large_file_url||e.representations&&e.representations.large||e.sample&&e.sample.url,e,t),this.sampleHeight=parseInt(e.sample_height||e.sample&&e.sample.height,10),this.sampleWidth=parseInt(e.sample_width||e.sample&&e.sample.width,10),this.previewUrl=parseImageUrl(e.preview_url||e.preview_file_url||e.representations&&e.representations.small||e.preview&&e.preview.url,e,t),this.previewHeight=parseInt(e.preview_height||e.preview&&e.preview.height,10),this.previewWidth=parseInt(e.preview_width||e.preview&&e.preview.width,10),this.id=e.id?e.id.toString():"No ID available",this.tags=getTags(e),e.score&&e.score.total?this.score=e.score.total:this.score=e.score?parseInt(e.score,10):e.score,this.source=e.source||e.sources||e.source_url,this.rating=e.rating||/(safe|suggestive|questionable|explicit)/i.exec(e.tags)||"u",Array.isArray(this.rating)&&(this.rating=this.rating[0]),"suggestive"===this.rating&&(this.rating="q"),this.rating=this.rating.charAt(0),this.createdAt=null,"object"==typeof e.created_at?this.createdAt=new Date(1e3*e.created_at.s+e.created_at.n/1e9):"number"==typeof e.created_at?this.createdAt=new Date(1e3*e.created_at):"number"==typeof e.change?this.createdAt=new Date(1e3*e.change):this.createdAt=new Date(e.created_at||e.date)}get file_url(){return this.fileUrl}get sample_url(){return this.sampleUrl}get sample_height(){return this.sampleHeight}get sample_width(){return this.sampleWidth}get preview_url(){return this.previewUrl}get preview_height(){return this.previewHeight}get preview_width(){return this.previewWidth}get postView(){return this.booru.postView(this.id)}get common(){return common(),this}}exports.default=Post;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Post.js","sourceRoot":"","sources":["../../src/structures/Post.ts"],"names":[],"mappings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AI,CAAC,SAAS,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,IAAI,CAAC,CAAA;SACxD;IACH,CAAC;IAMD,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,OAAO,CAAA;IACrB,CAAC;IAMD,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,SAAS,CAAA;IACvB,CAAC;IAMD,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,YAAY,CAAA;IAC1B,CAAC;IAMD,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,WAAW,CAAA;IACzB,CAAC;IAMD,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,UAAU,CAAA;IACxB,CAAC;IAMD,IAAI,cAAc;QAChB,OAAO,IAAI,CAAC,aAAa,CAAA;IAC3B,CAAC;IAMD,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,YAAY,CAAA;IAC1B,CAAC;IAeD,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACrC,CAAC;IAkBD,IAAI,MAAM;QACR,MAAM,EAAE,CAAA;QACR,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AAvND,uBAuNC"}
@@ -1,7 +1,8 @@
1
- export default interface SearchParameters {
1
+ import { BooruCredentials } from '../boorus/Booru';
2
+ export default interface SearchParameters {
2
3
  limit?: number;
3
4
  random?: boolean;
4
5
  page?: number;
5
- credentials?: any;
6
+ credentials?: BooruCredentials;
6
7
  showUnavailable?: boolean;
7
8
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SearchParameters.js","sourceRoot":"","sources":["../../src/structures/SearchParameters.ts"],"names":[],"mappings":""}
@@ -1,7 +1,7 @@
1
1
  import Booru from '../boorus/Booru';
2
2
  import Post from '../structures/Post';
3
3
  import SearchParameters from './SearchParameters';
4
- declare class SearchResults extends Array<Post> {
4
+ export default class SearchResults extends Array<Post> {
5
5
  booru: Booru;
6
6
  page: number;
7
7
  readonly tags: string[];
@@ -16,4 +16,3 @@ declare class SearchResults extends Array<Post> {
16
16
  }): SearchResults;
17
17
  blacklist(tags: string[] | string): SearchResults;
18
18
  }
19
- export default SearchResults;
@@ -1 +1 @@
1
- "use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(t,e,r,s){void 0===s&&(s=r),Object.defineProperty(t,s,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,s){void 0===s&&(s=r),t[s]=e[r]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),__importStar=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)"default"!==r&&Object.prototype.hasOwnProperty.call(t,r)&&__createBinding(e,t,r);return __setModuleDefault(e,t),e};Object.defineProperty(exports,"__esModule",{value:!0});const Utils=__importStar(require("../Utils"));class SearchResults extends Array{constructor(t,e,r,s){super(t.length);for(let e=0;e<t.length;e++)this[e]=t[e];this.posts=t,this.tags=e,this.options=r,this.booru=s,this.page=r&&r.page||0}get first(){return this[0]}get last(){return this[this.length-1]}nextPage(){const t=this.options;return t.page=this.page+1,this.booru.search(this.tags,t)}tagged(t,{invert:e=!1}={}){Array.isArray(t)||(t=[t]);const r=[];for(const s of this){const o=Utils.compareArrays(t,s.tags).length;(!e&&o>0||e&&0===o)&&r.push(s)}return new SearchResults(r,this.tags,this.options,this.booru)}blacklist(t){return this.tagged(t,{invert:!0})}}const prototypeKeys=Reflect.ownKeys(Array.prototype).filter((t=>"string"==typeof t&&"constructor"!==t));for(const t of prototypeKeys)if("function"==typeof Array.prototype[t]){const e=function(...e){return this.posts[t](...e)};Object.defineProperty(SearchResults.prototype,t,{value:e})}exports.default=SearchResults;
1
+ "use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(t,e,s,r){void 0===r&&(r=s),Object.defineProperty(t,r,{enumerable:!0,get:function(){return e[s]}})}:function(t,e,s,r){void 0===r&&(r=s),t[r]=e[s]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),__importStar=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var s in t)"default"!==s&&Object.prototype.hasOwnProperty.call(t,s)&&__createBinding(e,t,s);return __setModuleDefault(e,t),e};Object.defineProperty(exports,"__esModule",{value:!0});const Utils=__importStar(require("../Utils"));class SearchResults extends Array{booru;page;tags;options;posts;constructor(t,e,s,r){super(t.length);for(let e=0;e<t.length;e++)this[e]=t[e];this.posts=t,this.tags=e,this.options=s,this.booru=r,this.page=s&&s.page||0}get first(){return this[0]}get last(){return this[this.length-1]}nextPage(){const t=this.options;return t.page=this.page+1,this.booru.search(this.tags,t)}tagged(t,{invert:e=!1}={}){Array.isArray(t)||(t=[t]);const s=[];for(const r of this){const i=Utils.compareArrays(t,r.tags).length;(!e&&i>0||e&&0===i)&&s.push(r)}return new SearchResults(s,this.tags,this.options,this.booru)}blacklist(t){return this.tagged(t,{invert:!0})}}exports.default=SearchResults;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SearchResults.js","sourceRoot":"","sources":["../../src/structures/SearchResults.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAOA,gDAAiC;AAqBjC,MAAqB,aAAc,SAAQ,KAAW;IAE7C,KAAK,CAAO;IAEZ,IAAI,CAAQ;IAEH,IAAI,CAAU;IAEd,OAAO,CAAkB;IAEzB,KAAK,CAAQ;IAG7B,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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;SACF;QAED,OAAO,IAAI,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,CAAA;IACtE,CAAC;IAOM,SAAS,CAAC,IAAuB;QACtC,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAA;IAC5C,CAAC;CACF;AAjGD,gCAiGC"}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});class Site{constructor(s){this.domain=s.domain,this.type=s.type||"json",this.aliases=s.aliases||[],this.nsfw=s.nsfw,this.api=s.api||{},this.paginate=s.paginate||"page",this.random=s.random||!1,this.tagQuery=s.tagQuery||"tags",this.insecure=s.insecure||!1,this.defaultTags=s.defaultTags||[]}}exports.default=Site;
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 @@
1
+ {"version":3,"file":"Site.js","sourceRoot":"","sources":["../../src/structures/Site.ts"],"names":[],"mappings":";;AAWA,MAAqB,IAAI;IAEhB,MAAM,CAAQ;IAEd,IAAI,CAAQ;IAEZ,OAAO,CAAU;IAEjB,IAAI,CAAS;IAEb,GAAG,CAAS;IAEZ,QAAQ,CAAQ;IAKhB,MAAM,CAAkB;IAExB,QAAQ,CAAQ;IAEhB,QAAQ,CAAS;IAEjB,WAAW,CAAU;IAE5B,YAAY,IAAc;QACxB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAA;QACzB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,MAAM,CAAA;QAC/B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,EAAE,CAAA;QACjC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAA;QACrB,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,EAAE,CAAA;QACzB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAA;QACvC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,KAAK,CAAA;QAClC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAA;QACvC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,IAAI,KAAK,CAAA;QACtC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,IAAI,EAAE,CAAA;IAC3C,CAAC;CACF;AArCD,uBAqCC"}
@@ -1,4 +1,4 @@
1
1
  export default interface SiteApi {
2
- search?: string;
3
- postView?: string;
2
+ search: string;
3
+ postView: string;
4
4
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SiteApi.js","sourceRoot":"","sources":["../../src/structures/SiteApi.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SiteInfo.js","sourceRoot":"","sources":["../../src/structures/SiteInfo.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,29 +1,29 @@
1
1
  {
2
2
  "name": "booru",
3
- "version": "2.3.3",
3
+ "version": "2.4.3",
4
4
  "description": "Search (and do other things) on a bunch of different boorus!",
5
- "author": "AtlasTheBot (https://github.com/AtlasTheBot/)",
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
9
  "runkitExampleFilename": "./dist/example.js",
10
- "homepage": "https://github.com/AtlasTheBot/booru#readme",
10
+ "homepage": "https://github.com/AtoraSuunva/booru#readme",
11
11
  "repository": {
12
12
  "type": "git",
13
- "url": "git+https://github.com/AtlasTheBot/booru.git"
13
+ "url": "git+https://github.com/AtoraSuunva/booru.git"
14
14
  },
15
15
  "bugs": {
16
- "url": "https://github.com/AtlasTheBot/booru/issues"
16
+ "url": "https://github.com/AtoraSuunva/booru/issues"
17
17
  },
18
18
  "scripts": {
19
- "test": "npx jest --no-cache",
20
- "lint": "npx tslint --fix -p . -c ./tslint.json ./src/**/*.ts",
21
- "clean": "npx rimraf ./dist",
22
- "prebuild": "npm run-script clean && npm run-script lint",
23
- "build": "npx tsc --sourceMap false",
24
- "build-dev": "npx tsc --sourceMap",
19
+ "test": "jest",
20
+ "lint": "eslint -c .eslintrc.js --ext .ts ./src",
21
+ "clean": "rimraf ./dist && rm tsconfig.tsbuildinfo",
22
+ "prebuild": "npm run clean && npm run lint",
23
+ "build": "tsc --sourceMap",
24
+ "build-dev": "tsc --sourceMap",
25
25
  "postbuild": "node ./minify.js",
26
- "prepublishOnly": "npm run-script build"
26
+ "prepublishOnly": "npm run build"
27
27
  },
28
28
  "keywords": [
29
29
  "booru",
@@ -44,24 +44,30 @@
44
44
  "node": ">=10.0.0"
45
45
  },
46
46
  "dependencies": {
47
- "fast-xml-parser": "^3.17.4",
47
+ "fast-xml-parser": "^3.19.0",
48
48
  "node-fetch": "^2.6.1"
49
49
  },
50
50
  "devDependencies": {
51
- "@babel/core": "^7.12.1",
51
+ "@babel/core": "^7.15.5",
52
52
  "@babel/polyfill": "^7.12.1",
53
- "@babel/preset-env": "^7.12.1",
54
- "@babel/preset-typescript": "^7.12.1",
55
- "@types/jest": "^26.0.14",
56
- "@types/node": "^14.11.8",
57
- "@types/node-fetch": "^2.5.7",
58
- "jest": "^26.5.3",
53
+ "@babel/preset-env": "^7.15.4",
54
+ "@babel/preset-typescript": "^7.15.0",
55
+ "@types/jest": "^27.0.1",
56
+ "@types/node": "^16.9.0",
57
+ "@types/node-fetch": "^2.5.12",
58
+ "@typescript-eslint/eslint-plugin": "^4.31.0",
59
+ "@typescript-eslint/parser": "^4.31.0",
60
+ "eslint": "^7.32.0",
61
+ "eslint-config-prettier": "^8.3.0",
62
+ "eslint-plugin-import": "^2.24.2",
63
+ "eslint-plugin-jsdoc": "^36.1.0",
64
+ "eslint-plugin-no-null": "^1.0.2",
65
+ "eslint-plugin-prefer-arrow": "^1.2.3",
66
+ "jest": "^27.1.1",
67
+ "prettier": "^2.3.2",
59
68
  "rimraf": "^3.0.2",
60
- "terser": "^5.3.5",
61
- "tslint": "^6.1.2",
62
- "typedoc": "^0.19.2",
63
- "typedoc-plugin-external-module-name": "^4.0.3",
64
- "typescript": "^4.0.3"
69
+ "terser": "^5.7.2",
70
+ "typescript": "^4.4.2"
65
71
  },
66
72
  "files": [
67
73
  "dist/"
@@ -84,8 +90,8 @@
84
90
  "url": "https://github.com/BobbyWibowo"
85
91
  },
86
92
  {
87
- "name": "AtlasTheBot",
88
- "url": "https://github.com/AtlasTheBot"
93
+ "name": "AtoraSuunva",
94
+ "url": "https://github.com/AtoraSuunva"
89
95
  }
90
96
  ]
91
97
  }
package/readme.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  ## Features
8
8
 
9
- - Search 16 different boorus (check [sites.json](./src/sites.json))
9
+ - Search 15 different boorus (check [sites.json](./src/sites.json))
10
10
  - Normalizes all received data into `Post` objects that are consistent no matter which booru you use
11
11
  - Access to the raw data received from the booru as well (transformed from XML to JSON, if applicable)
12
12
  - Alias support for boorus (`sb` for `safebooru.org`)
package/CHANGELOG.md DELETED
@@ -1,58 +0,0 @@
1
- # booru Changelog
2
-
3
- ## 2.3.3 [Latest]
4
-
5
- - Fix Paheal failing to provide a useful error message.
6
- - Details: Paheal was returning an HTML error page instead of a JSON response. The previous way
7
- of scraping an error message off HTML pages failed on the page Paheal returned.
8
- - Move from `terser-folder` to a custom `minify.js`, which handles both .js and .json minifying
9
- - `terser-folder` also hasn't been updated in 2 years
10
- - Update circle ci to use node 14 instead of 11
11
- - Update dependencies, no more security vulnerabilities!
12
-
13
- ## 2.3.2
14
-
15
- - Added `Post#available`, to check if a post isn't deleted/banned
16
- - By default, unavailable posts aren't returned in search results
17
- - You can use `SearchParameters#showUnavailable` to still get them
18
- - `Booru.search('db', ['cat'], { showUnavailable: true })`
19
- - Fix for danbooru occasionally having invalid `fileUrl` or missing IDs
20
- - You can use `Post#available` to check for this
21
-
22
- ## 2.3.0
23
-
24
- - Fix for illegal invocation errors when using booru on the web
25
- - Some of the APIs don't have the required CORS headers however
26
- - Add `encodeURI` to tags when searching, to avoid encoding errors from the API
27
- - Better example.js file, now supports command line input
28
- - Remove lolibooru
29
-
30
- ## 2.2.3
31
-
32
- - Various fixes for Derpibooru support
33
-
34
- ## 2.2.2
35
-
36
- - Fix default tags missing from post results
37
- - Fix scores/sources/createdAt post props for some sites
38
-
39
- ## 2.2.1
40
-
41
- - Added missing check for `results.posts` in API response
42
-
43
- ## 2.2.0
44
-
45
- - Support for e621/e926's new api
46
- - Fix BooruError wiping out stack trace of caught error
47
- - Dependency updates
48
-
49
- ## 2.1.0
50
-
51
- - Update dependencies
52
- - Fix typo in "hypo" for hypnohub's aliases #42
53
- - Workaround for JS projects trying to use `new booru(site)` #40
54
- - Will still "work" for certain projects, but now `booru.forSite(site)` is preferred
55
-
56
- ## 2.0.5
57
-
58
- - Last release before changelog started