Git Product home page Git Product logo

derpybooru's Introduction

DerPyBooru-Nullforce

Python bindings for Derpibooru's API

License: Simplified BSD License

Version Version
Python Versions
Downloads Downloads

About this Fork

This is a fork of the joshua-stone/DerPyBooru repository; it is meant to be a drop in replacement for the modules in that package.

Features

  • High-level abstraction over Derpibooru's REST API
  • Parameter chaining for ease of manipulation
  • Syntactic sugar for queries, e.g., "query.score >= 100" compiling to "score.gte:100"
  • Design focusing on iterables and lazy generation for network efficiency

Dependencies

  • python 2.7, 3.0 or newer
  • requests

How to install

  pip install derpybooru-nullforce

Checking documentation

  pydoc derpibooru

Typical usage

Getting images currently on Derpibooru's front page

from derpibooru import Search

for image in Search():
  id_number, score, tags = image.id, image.score, ", ".join(image.tags)
  print("#{} - score: {:>3} - {}".format(id_number, score, tags))

Searching posts by tag

from derpibooru import Search

for image in Search().query("rarity", "twilight sparkle"):
  print(image.url)

Crawling Derpibooru from first to last post

from derpibooru import Search

# This is only an example and shouldn't be used in practice as it abuses
# Derpibooru's licensing terms
for image in Search().ascending().limit(None):
  id_number, score, tags = image.id, image.score, ", ".join(image.tags)
  print("#{} - score: {:>3} - {}".format(id_number, score, tags))

Getting random posts

from derpibooru import Search, sort

for post in Search().sort_by(sort.RANDOM):
  print(post.url)

Getting top 100 posts

from derpibooru import Search, sort

top_scoring = [post for post in Search().sort_by(sort.SCORE).limit(100)]

Storing and passing new search parameters

from derpibooru import Search, sort

params = Search().sort_by(sort.SCORE).limit(100).parameters

top_scoring = Search(**params)
top_animated = top_scoring.query("animated")

Filtering by metadata

from derpibooru import Search, query

q = {
  "wallpaper",
  query.width == 1920,
  query.height == 1080,
  query.score >= 100
}

wallpapers = [image for image in Search().query(*q)]

Getting the latest images from a watchlist

from derpibooru import Search, user

key = "your_api_key"

for post in Search().key(key).watched(user.ONLY):
  id_number, score, tags = post.id, post.score, ", ".join(post.tags)
  print("#{} - score: {:>3} - {}".format(id_number, score, tags))

Changelog

See CHANGELOG

[1.0.0]

Added

  • Now uses the API introduced with Philomena

Removed

  • Older derpibooru API calls

derpybooru's People

Contributors

gsass1 avatar joshua-stone avatar liamwhite avatar luckydonald avatar nullforce avatar shikogo avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.