Skip to content

Commit

Permalink
Merge pull request #53 from AtlasTheBot/2.3.0-release
Browse files Browse the repository at this point in the history
2.3.1 release
  • Loading branch information
D. Plaza committed Jul 6, 2020
2 parents ecbbba5 + 72d3815 commit dd60b07
Show file tree
Hide file tree
Showing 9 changed files with 1,419 additions and 1,511 deletions.
49 changes: 39 additions & 10 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,39 @@
# booru Changelog

## 2.1.0 [Latest]
- Update dependencies
- Fix typo in "hypo" for hypnohub's aliases #42
- Workaround for JS projects trying to use `new booru(site)` #40
- Will still "work" for certain projects, but now `booru.forSite(site)` is preferred

## 2.0.5
- Last release before changelog started
# booru Changelog

## 2.3.0 [Latest]

- Fix for illegal invocation errors when using booru on the web
- Some of the APIs don't have the required CORS headers however
- Add `encodeURI` to tags when searching, to avoid encoding errors from the API
- Better example.js file, now supports command line input
- Remove lolibooru

## 2.2.3

- Various fixes for Derpibooru support

## 2.2.2

- Fix default tags missing from post results
- Fix scores/sources/createdAt post props for some sites

## 2.2.1

- Added missing check for `results.posts` in API response

## 2.2.0

- Support for e621/e926's new api
- Fix BooruError wiping out stack trace of caught error
- Dependency updates

## 2.1.0

- Update dependencies
- Fix typo in "hypo" for hypnohub's aliases #42
- Workaround for JS projects trying to use `new booru(site)` #40
- Will still "work" for certain projects, but now `booru.forSite(site)` is preferred

## 2.0.5

- Last release before changelog started
16 changes: 8 additions & 8 deletions minifyJson.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(async () => {
const fs = require('fs').promises
const [,,from,to] = process.argv
if (!from || !to) throw new Error('No file to minify, or no output')
const content = await fs.readFile(from, 'utf8')
await fs.writeFile(to, JSON.stringify(JSON.parse(content)), 'utf8')
console.log(`Minified ${from} to ${to}!`)
})()
(async () => {
const fs = require('fs').promises
const [,,from,to] = process.argv
if (!from || !to) throw new Error('No file to minify, or no output')
const content = await fs.readFile(from, 'utf8')
await fs.writeFile(to, JSON.stringify(JSON.parse(content)), 'utf8')
console.log(`Minified ${from} to ${to}!`)
})()
2,237 changes: 1,063 additions & 1,174 deletions package-lock.json

Large diffs are not rendered by default.

21 changes: 10 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "booru",
"version": "2.2.3",
"version": "2.3.1",
"description": "Search (and do other things) on a bunch of different boorus!",
"author": "AtlasTheBot (https://github.com/AtlasTheBot/)",
"license": "MIT",
Expand Down Expand Up @@ -38,7 +38,6 @@
"tbib",
"xbooru",
"paheal",
"lolibooru",
"derpibooru"
],
"engines": {
Expand All @@ -49,21 +48,21 @@
"node-fetch": "^2.6.0"
},
"devDependencies": {
"@babel/core": "^7.10.2",
"@babel/polyfill": "^7.10.1",
"@babel/preset-env": "^7.10.2",
"@babel/preset-typescript": "^7.10.1",
"@types/jest": "^26.0.0",
"@types/node": "^14.0.13",
"@babel/core": "^7.10.4",
"@babel/polyfill": "^7.10.4",
"@babel/preset-env": "^7.10.4",
"@babel/preset-typescript": "^7.10.4",
"@types/jest": "^26.0.4",
"@types/node": "^14.0.18",
"@types/node-fetch": "^2.5.7",
"jest": "^26.0.1",
"jest": "^26.1.0",
"rimraf": "^3.0.2",
"terser": "^4.8.0",
"terser-folder": "^2.0.0",
"tslint": "^6.1.2",
"typedoc": "^0.17.7",
"typedoc": "^0.17.8",
"typedoc-plugin-external-module-name": "^4.0.3",
"typescript": "^3.9.5"
"typescript": "^3.9.6"
},
"files": [
"dist/"
Expand Down
238 changes: 122 additions & 116 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,116 +1,122 @@
# `booru`

> *A node package to search boorus*
[![CircleCI](https://img.shields.io/circleci/project/github/AtlasTheBot/booru.svg)](https://circleci.com/gh/AtlasTheBot/booru) ![npm](https://img.shields.io/npm/v/booru.svg) ![GitHub](https://img.shields.io/github/license/AtlasTheBot/booru.svg) ![Typescript typings](https://img.shields.io/badge/Typings-Typescript-informational.svg)

## Features

- Search 17 different boorus (check [sites.json](./src/sites.json))
- Normalizes all received data into `Post` objects that are consistent no matter which booru you use
- Access to the raw data received from the booru as well (transformed from XML to JSON, if applicable)
- Alias support for boorus (`sb` for `safebooru.org`)
- Promises
- Types (using Typescript)
- Choose the amount of images to get
- Random support for all sites, using `order:random` on sites that support it and using custom code on those that don't
- Coming soon(-ish): Support for more than just searching

---

## Installation

```sh
npm add booru
# or
yarn add booru
```

---

## Usage

```js
const Booru = require('booru')

Booru.search('safebooru', ['glaceon'], { limit: 3, random: true })
.then(posts => {
for (let post of posts)
console.log(post.fileUrl, post.postView)
})

// or (using alias support and creating boorus)
const sb = Booru.forSite('sb')

sb.search(['cat', 'dog'], { limit: 2 })
```

See [example.js](./example.js) for more examples

---

## Docs

Available here: [https://booru.js.org](https://booru.js.org)

## FAQ

### What are the properties of a `Post`?

The basic structure of a `Post` object looks like:

```js
Post {
_data: {/*...*/}, // The raw data from the booru
fileUrl: 'https://aaaa.com/img.jpg', // The direct link to the image, ready to post
id: '124125', // The image ID, as a string
tags: ['cat', 'cute'], // The tags, split into an Array
score: 5, // The score as a Number
source: 'https://ex.com/aaa.png', // Source of the image, if supplied
rating: 's', // Rating of the image
createdAt: Date, // The `Date` this image was created at
postView: 'https://booru.ex/show/12345' // A URL to the post
}
```

`s`: 'Safe'
`q`: 'Questionable'
`e`: 'Explicit'
`u`: 'Unrated'

Derpibooru has `Safe, Suggestive, Questionable, Explicit`, although `Suggestive` will be shown as `q` in `<Post>.rating`

### Can I contribute?

Sure! Just fork this repo, push your changes, and then make a PR.

I'll accept PR based on what they do and code style (Not super strict about it, but it's best if it roughly follows the rest of the code)

### Why?

Why not?

### License?

[It's MIT](https://choosealicense.com/licenses/mit/)

---

## Contributors

[BobbyWibowo](https://github.com/BobbyWibowo/booru)
> [Change from request-promise-native to snek-fetch](https://github.com/AtlasTheBot/booru/pull/9)
[rubikscraft](https://github.com/rubikscraft/booru)
> [Add 2 new boorus (furry.booru.org/realbooru.com)](https://github.com/AtlasTheBot/booru/pull/17)
> [Various Derpibooru fixes](https://github.com/AtlasTheBot/booru/pull/19)
[Favna](https://github.com/favna/)
> [Add TypeScript declarations](https://github.com/AtlasTheBot/booru/pull/21)
> Improve TypeScript port
> Various other small fixes
[negezor](https://github.com/negezor)
> [Add missing type information](https://github.com/AtlasTheBot/booru/pull/31)
---
# `booru`

> *A node package to search boorus*
[![CircleCI](https://img.shields.io/circleci/project/github/AtlasTheBot/booru.svg)](https://circleci.com/gh/AtlasTheBot/booru) ![npm](https://img.shields.io/npm/v/booru.svg) ![GitHub](https://img.shields.io/github/license/AtlasTheBot/booru.svg) ![Typescript typings](https://img.shields.io/badge/Typings-Typescript-informational.svg)

## Features

- Search 16 different boorus (check [sites.json](./src/sites.json))
- Normalizes all received data into `Post` objects that are consistent no matter which booru you use
- Access to the raw data received from the booru as well (transformed from XML to JSON, if applicable)
- Alias support for boorus (`sb` for `safebooru.org`)
- Promises
- Types (using Typescript)
- Choose the amount of images to get
- Random support for all sites, using `order:random` on sites that support it and using custom code on those that don't
- Coming soon(-ish): Support for more than just searching

---

## Installation

```sh
npm add booru
# or
yarn add booru
```

---

## Usage

```js
const Booru = require('booru')

Booru.search('safebooru', ['glaceon'], { limit: 3, random: true })
.then(posts => {
for (let post of posts)
console.log(post.fileUrl, post.postView)
})

// or (using alias support and creating boorus)
const sb = Booru.forSite('sb')

sb.search(['cat', 'dog'], { limit: 2 })
```

See [example.js](./example.js) for more examples

---

## Docs

Available here: [https://booru.js.org](https://booru.js.org)

## Web support

booru was built for Node.js, and is only officially supported for Node.js. Issues relating to web are fine, although support might be limited.

It's possible to use booru on the web using webpack (or similar), although your experience may vary. Some websites don't have the proper CORS headers, meaning that API requests to those sites from a browser will fail! This is not an issue I can fix in the package, and requires either that booru to add proper support themselves or for you to find a workaround for CORS.

## FAQ

### What are the properties of a `Post`?

The basic structure of a `Post` object looks like:

```js
Post {
_data: {/*...*/}, // The raw data from the booru
fileUrl: 'https://aaaa.com/img.jpg', // The direct link to the image, ready to post
id: '124125', // The image ID, as a string
tags: ['cat', 'cute'], // The tags, split into an Array
score: 5, // The score as a Number
source: 'https://ex.com/aaa.png', // Source of the image, if supplied
rating: 's', // Rating of the image
createdAt: Date, // The `Date` this image was created at
postView: 'https://booru.ex/show/12345' // A URL to the post
}
```

`s`: 'Safe'
`q`: 'Questionable'
`e`: 'Explicit'
`u`: 'Unrated'

Derpibooru has `Safe, Suggestive, Questionable, Explicit`, although `Suggestive` will be shown as `q` in `<Post>.rating`

### Can I contribute?

Sure! Just fork this repo, push your changes, and then make a PR.

I'll accept PR based on what they do and code style (Not super strict about it, but it's best if it roughly follows the rest of the code)

### Why?

Why not?

### License?

[It's MIT](https://choosealicense.com/licenses/mit/)

---

## Contributors

[BobbyWibowo](https://github.com/BobbyWibowo/booru)
> [Change from request-promise-native to snek-fetch](https://github.com/AtlasTheBot/booru/pull/9)
[rubikscraft](https://github.com/rubikscraft/booru)
> [Add 2 new boorus (furry.booru.org/realbooru.com)](https://github.com/AtlasTheBot/booru/pull/17)
> [Various Derpibooru fixes](https://github.com/AtlasTheBot/booru/pull/19)
[Favna](https://github.com/favna/)
> [Add TypeScript declarations](https://github.com/AtlasTheBot/booru/pull/21)
> Improve TypeScript port
> Various other small fixes
[negezor](https://github.com/negezor)
> [Add missing type information](https://github.com/AtlasTheBot/booru/pull/31)
---
15 changes: 0 additions & 15 deletions src/sites.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,21 +169,6 @@
"paginate": "pid",
"random": false
},
"lolibooru.moe": {
"domain": "lolibooru.moe",
"aliases": [
"lb",
"lol",
"loli",
"lolibooru"
],
"nsfw": true,
"api": {
"search": "/post/index.json?",
"postView": "/post/show/"
},
"random": true
},
"rule34.paheal.net": {
"domain": "rule34.paheal.net",
"type": "xml",
Expand Down

0 comments on commit dd60b07

Please sign in to comment.