booru-scripts

Sync your favorites on moebooru websites to your own danbooru website. 同步你在 moebooru 网站上的收藏到你自己的 danbooru 网站。

Stars
3

booru-scripts

Incrementally sync your favorites on moebooru websites to your own danbooru website.

In this repo, moebooru typically means konachan.com and yande.re.

moebooru danbooru

moebooru konachan.com yande.re

Use-case

As computer nerds and anime/manga art lovers, everyone wants their favorite images on moebooru to be stored locally, so that we can appreciate them later. However, if you just download them to you hard drive, there are no longer tags (a big feature in image boards like moebooru) holding the images together. With no tags, you will have a hard time finding related images by tags. Also, viewing the large original files is a suboptimal experience, especially for mobile devices.

Even when you try to use some photo-management software to organize the images (e.g. use Apple Photos and AppleScript to automate image-tagging), tagging all those images is still a pain in the ass, let alone the experience is still behind *booru for this purpose.

Why not self-hosting a danbooru instance and use this script to sync your favorite images on moebooru to your own website! You will have the same experience as moebooru websites with all the advantages of self-hosted websites. (since moebooru is a fork from danbooru, they are similar.)

anime/manga moebooru ~~~~~~~~~~~~ tag moebooru image boards tag tag ~~//~~

Apple Photos AppleScript ~~~~ *booru

danbooru moebooru moebooru moebooru danbooru fork

This script will first download the original images and metadata of your favorites posts from moebooru. Then it will create posts on your danbooru instance with the downloaded image and metadata.

moebooru danbooru posts

Since there is no direct access to moebooru websites like konachan.com or yande.re in my country, the script will download the images first (proxy configurable) and then upload them to self-host danbooru instance. Otherwise the self-hosted danbooru instance is able to directly fetch them (although the danbooru instance is able to use a proxy).

konachan.com yande.re danbooru danbooru

Screenshot of a self-hosting danbooru instance, with metadata of posts synced (see todo for supported metadata):

danbooru todo

How to use

Make sure GNU make, curl, wget, node, and yarn are installed. Steps below are based on a unix-like OS. If you are using Windows, try WSL.

GNU make, curl, wget, node yarn Unix Windows WSL

If it is your first time running this script, run yarn install to install dependencies. yarn install

  1. Prepare environment variables

    • MOEBOORU_USERNAME: your username on moebooru

      • set it by export MOEBOORU_USERNAME=username
    • MOEBOORU_HOST: moebooru host, e.g. https://konachan.com (don't forget http/https)

      • set it by export MOEBOORU_HOST=https://konachan.com
    • DANBOORU_HOST: your self-hosted danbooru, e.g. https://danbooru.example.com (don't forget http/https)

      • set it by export DANBOORU_HOST=https://konachan.com
      • (recommanded) or putting DANBOORU_HOST=https://konachan.com in a .env file at repo root
    • DANBOORU_USERNAME: username of your self-hosted danbooru account

      • set it by export DANBOORU_USERNAME=username
      • (recommanded) or putting DANBOORU_USERNAME=username in a .env file at repo root
    • DANBOORU_APIKEY: api key of your self-hosted danbooru account (you can create one from account profile page)

      • set it by export DANBOORU_APIKEY=key
      • (recommanded) or putting DANBOORU_APIKEY=key in a .env file at repo root
    • PROXY: proxy to use when accessing moebooru websites (because there is no direct access in my country), e.g. http://127.0.0.1:9999

      • skip this if you don't need a proxy
      • set it by export PROXY=http://yourproxy:1234
    • IMAGE_DIR: path to directory, where to store downloaded images

      • default value: ~/Pictures/${MOEBOORU_HOSTNAME}. For example, if you set MOEBOORU_HOST as https://konachan.com, then IMAGE_DIR will be ~/Pictures/konachan.com
      • set it by export IMAGE_DIR=./your-dir
  2. Start syncing

    • Run make get_favorites_and_sync_to_danbooru to download and sync your favorites to self-hosted danbooru incrementally (tags will also be synced).
    • Run make get-and-update-tags-all to sync tag metadata from moebooru to self-hosted danbooru. Since this is about tag metadata, not the tags of an image, you don't need to run this frequently (typically they won't change).
    • More actions will be added later after some testing... You can read the targets in Makefile to see what they do.

TODO

  • Sync images, tags, rating, and source
  • Sync metadata for tags
  • Sync parent/child relationships
  • Sync pools