Python bindings for Derpibooru's API
Project description
DerPyBooru
Python bindings for Derpibooru's API
License: Simplified BSD License
Version: 0.9.0
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
- python2.7 or newer
- requests
About this Fork
This is a fork of the DerPyBooru package; it is meant to be a drop in replacement for the modules in that package.
To use, use derpybooru_nullforce
where you see derpybooru
used below.
How to install
Python 2.7
$ pip install derpybooru-nullforce
Python 3.x
$ pip3 install derpybooru-nullforce
Checking documentation
Python 2.7
$ pydoc derpibooru
Python 3.x
$ pydoc3 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
0.9.0
- Update sort to include: first_seen_at, tag_count, and updated_at
- Deprecated Search() methods that appear to be no longer supported by derpibooru:
- faves()
- uploads()
- upvotes()
- watched()
0.8.0
- Updated sort to include wilson and width
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for DerPyBooru_Nullforce-0.9.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea9cbc9eb5b21ee35a34f3f9f01fb3eeae831bd089716e36ba257fb8a7cc7228 |
|
MD5 | 7946405b2f821e26e2bc88039764a225 |
|
BLAKE2b-256 | 4319c24a702dfe08eca85e388ba049e7092eda98cabd4bd09deda26df3f5004b |
Close
Hashes for DerPyBooru_Nullforce-0.9.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4950825ff3450197efa302943b6dc190e536a94e9830ce2c587f31ba39b279a0 |
|
MD5 | 3ef9185afb44976a2439e65a2e1bd434 |
|
BLAKE2b-256 | 665a5a1415219625ac3c7a4de5e7ad66529440d7b93ea5e4e99c0b8d047b6e0e |