npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

es6-booru

v0.4.4

Published

Search a bunch of different boorus using package magic!

Downloads

33

Readme

booru

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

Features

  • Able to search 17 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 booru

Or if you use yarn

yarn add booru

Usage

const booru = require('booru')

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)
  }
})

Docs

booru.search(site, tags, options)

| Parameter | Type | Optional | Default | Description | |-----------|:-------------:|:--------:|:-------:|-------------| | site | string | | none | The site to search, supports aliases | tags | string[] | X | [] | The tags to search with | options | SearchOptions | X | {} | For amount of images to fetch and if to return a random result or not (Check below table)

SearchOptions ({limit: 1, random: false})

| Parameter | Type | Optional | Default | Description | |-----------|:-------------:|:--------:|:-------:|-------------| | limit | number | X | 1 | The max amount of images to return | random | boolean | X | false | If the images returned should be random everytime


Contributors

BobbyWibowo

Change from request-promise-native to snek-fetch


FAQ

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://giraffeduck.com/aaa.png',//source of the image, if supplied
  rating: 's'                               //rating of the image
}

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

Derpibooru has Safe, Suggestive, Questionable, Explicit, although Suggestive will be shown as q in image.common

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?

This is terrible code

:)

License?

It's GPLv3