Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sfwbooru

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sfwbooru

Search different sfw boorus!

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

booru

A mode package for searching various boorus (with promises!)

Exact copy from booru just removed the nsfw sites

Features

  • Able to search 5 different boorus (check sites.json)
  • Also alias support so you can be lazy (sb for safebooru.org)
  • Promises because they're magical
  • Little utility to convert xml to json (and add a .common prop to each image)
  • Choose the amount of images to get
  • Random support for all sites, using order:random on sites that support it and using a bit of magic on sites that don't
  • Some other stuff I probably forgot

Installation

npm i --save sfwbooru

Usage

const booru = require('sfwbooru')

booru.search(site, [tag1, tag2], {limit: 1, random: false})
.then(booru.commonfy)
.then(images => {
  //Log the direct link to each image
  for (let image of images) {
    console.log(image.common.file_url)
  }
})
.catch(err => {
  if (err.name === 'booruError') {
    //It's a custom error thrown by the package
    console.log(err.message)
  } else {
    //This means I messed up. Whoops.
    console.log(err)
  }
})

Some docs

booru.search(site, tags, options)
ParameterTypeOptionalDefaultDescription
sitestringnoneThe site to search, supports aliases
tagsstring[]X[]The tags to search with
optionsSearchOptionsX{}For amount of images to fetch and if to return a random result or not (Check below table)
SearchOptions ({limit: 1, random: false})
ParameterTypeOptionalDefaultDescription
limitnumberX1The max amount of images to return
randombooleanXfalseIf the images returned should be random everytime

FAQ

who am i kidding nobody asks me questions

What the ".common prop" do?

Calling booru.commonfy not only transforms all the xml into json, it adds a .common prop to each image

common: {
  file_url: 'https://aaaa.com/image.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://giraffedu.ck/aaaa.png', //source of the image, if supplied
  rating: 's'                              //rating of the image
}
License?

It's GPLv3

Keywords

FAQs

Package last updated on 18 Apr 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc