Python package and script collection to manage your szurubooru image board.
Usage: szuru-toolkit [OPTIONS] COMMAND [ARGS]...
Toolkit to manage your szurubooru image board.
Defaults can also be set in a config file.
Visit https://github.com/reluce/szurubooru-toolkit for more information.
Options:
--url TEXT Base URL to your szurubooru instance.
--username TEXT Username which will be used to authenticate with the szurubooru API.
--api-token TEXT API token for the user which will be used to authenticate with the szurubooru API.
--public If your szurubooru instance is reachable from the internet (default: False).
--log-enabled Create a log file (default: False).
--log-colorized Colorize the log output (default: True).
--log-file TEXT Output file for the log (default: szurubooru_toolkit.log)
--log-level [DEBUG|INFO|WARNING|ERROR|CRITICAL]
Set the log level (default: INFO).
--hide-progress Hides the progress bar (default: False).
-h, --help Show this message and exit.
Commands:
auto-tagger Tag posts automatically
create-relations Create relations between character and parody tag categories
create-tags Create tags based on a tag file or query
delete-posts Delete posts
import-from-booru Download and tag posts from various Boorus
import-from-url Download images from URLS or file containing URLs
reset-posts Remove tags and sources
tag-posts Tag posts manually
upload-media Upload media files
In order to run szuru-toolkit
, Python 3.11
is required.
This package is available on PyPI and can be installed with pip:
pip install szurubooru-toolkit
Alternatively, you can clone the package from GitHub and set everything up with Poetry. In the root directory of this repository, execute poetry install
.
If you would like to run the toolkit in a Docker container instead, follow the instructions below.
While the script szuru-toolkit
can run with just command line options, you can also set your options in a config file.
The script looks for a config.toml
file in following locations:
szuru-toolkit
is executed~/.config/szurubooru-toolkit/config.toml
/etc/szurubooru-toolkit/config.toml
szuru-toolkit
is executed$USERPROFILE/szurubooru-toolkit/config.toml
$APPDATA/szurubooru-toolkit/config.toml
Options passed to the szuru-toolkit
script take priority over the config file.
You can find a sample config file in the GitHub repository of this package.
Note that path names have to be specified with forward slashes (/) if you're using Windows.
Creating a SauceNAO account and an API key is recommended. Please consider supporting the SauceNAO team as well by upgrading your plan. With a free plan, you can request up to 200 posts in 24h.
For Deepbooru support, download the current release here (v3-20211112-sgd-e28) and extract the contents of the zip file. Specify the path of the folder with the extracted files in deepbooru_model
.
Please note that you have to set deepbooru_enabled
if you want to use it.
Following commands are currently available:
auto-tagger
: Tag posts automaticallycreate-relations
: Create relations between character and parody tag categoriescreate-tags
: Create tags based on a tag file or querydelete-posts
: Delete postsimport-from-booru
: Download and tag posts from various Boorusimport-from-url
: Batch importing of URLs based on gallery-dlreset-posts
: Remove tags and sourcestag-posts
: Tag posts manuallyupload-media
: Upload media filesCheck szuru-toolkit -h
or szuru-toolkit COMMAND -h
for a detailed description of supported options.
If you cloned the repo from GitHub, prefix the above scripts with poetry run
, e.g. poetry run szuru-toolkit auto-tagger "date:today"
. Note that your current working directory has to be the the root of the GitHub project.
If your query starts with a dash (-
), for example to negate a tag, you have to separate the query from the command with two dashes (This doesn't work with poetry run):
szuru-toolkit auto-tagger --no-deepbooru -- "-foo bar"
While most commands are self explanatory, the following require a bit of extra attention:
Examples
szuru-toolkit create-relations hitori_bocchi
threshold
under [create-relations]
in config.toml
.If no tag_file
is specified, the script will download the most recent 100 tags from Danbooru which have been used at least ten times.
You can use tools like Grabber to download a tag list from common boorus.
The tag_file
has to be in following format:
<tag_a>,<category_name>
<tag_b>,<category_name>
<tag_..n>,<category_name>
The category has to be created beforehand manually (e.g. default, artist, parody/series, character and meta).
Examples
szuru-toolkit create-tags
szuru-toolkit create-tags --query genshin* --overwrite
szuru-toolkit create-tags --tag-file tags.txt
This scripts imports posts with their tags from the URL passed to this script. In the background, it simply calls the gallery-dl script and parses its output. Alternatively, an input file with multiple URLs can be specified.
It's recommended to use the --cookie
flag for authentication, check https://github.com/mikf/gallery-dl#cookies for details.
Usage Examples
szuru-toolkit import-from-url "https://danbooru.donmai.us/posts?tags=foo"
szuru-toolkit import-from-url "https://chan.sankakucomplex.com/?tags=foo"
szuru-toolkit import-from-url "https://beta.sankakucomplex.com/post/show/<id>"
szuru-toolkit import-from-url --cookies "~/cookies.txt" --range ":100" ""https://twitter.com/<USERNAME>/likes"
szuru-toolkit import-from-url --input-file urls.txt "https://danbooru.donmai.us/posts?tags=foo" "https://beta.sankakucomplex.com/post/show/<id>"
GitHub repo icon: Code icons created by Smashicons - Flaticon