9-FS / nhentai_archivist

downloads hentai from nhentai.net and converts to CBZ
MIT License
114 stars 6 forks source link
backup cbz cross-platform datahoarder docker docker-compose doujinshi downloader executable hentai linux manga nhentai nhentai-archivist nhentai-downloader nhentai-tool rule34 rust self-hosted windows

nhentai_archivist

[!IMPORTANT] If you have any questions, please consult the readme first.

I spend a lot of effort to keep the readme up-to-date and chances are high that your problem has already been addressed here. If you still require assistance after reading the readme, post it publicly, preferably as a GitHub issue, so others can benefit from the troubleshooting as well.

Introduction

nHentai Archivist is a tool to download hentai from https://nhentai.net and convert them to CBZ files. From quickly downloading a few hentai specified in the console, downloading a few hundred hentai specified in a downloadme.txt, up to automatically keeping a massive self-hosted library up-to-date by automatically generating a downloadme.txt from a search by tag. (For that use-case it has been optimised to tag the CBZ files in a way that Komga in oneshot mode interprets everything correctly.)

Why CBZ? CBZ is a widespread standard and basically just a ZIP file containing the images and a metadata file. This enables nHentai Archivist to keep the tags which wouldn't be possible with PDF as far as I know.

Big thanks go out to h3nTa1m4st3r_xx69, who helped me with using nHentai's completely undocumented API. Without him this project could not have been reactivated. I'm happy about anyone who finds my software useful and feedback is also always welcome. Happy downloading~

Quick Start

  1. Execute the program once to create a default ./config/.env.
  2. Execute the program again and enter the nHentai ID you want to download separated by spaces.

Installation

  1. Execute the program once to create a default ./config/.env.\ This means that in the directory of the executable, there should now be a directory called "config" containing a file called ".env". You might need to enable seeing hidden files in the file explorer.
  2. I recommend setting the CSRFTOKEN cookie and USER_AGENT. If you start having problems with nHentai's bot protection (error 403), setting these is mandatory. If a CF_CLEARANCE cookie is available, it should be set as well.

[!NOTE] If nHentai has "under attack" mode enabled, clearing the Cloudflare prompt and updating CF_CLEARANCE seem to be required daily.

Further Settings

[!WARNING] I advise against running multiple instances of nHentai Archivist at the same time.

Usage

Download a Few Quickly

  1. Run the program as is. Do not set NHENTAI_TAGS and make sure there is no file at DOWNLOADME_FILEPATH.
  2. Enter the nHentai ID you want to download separated by spaces. This might not work using docker.

Example ./config/.env:

DATABASE_URL = "./db/db.sqlite"
LIBRARY_PATH = "./hentai/"

Download a Bit More From a File

  1. Do not set NHENTAI_TAGS.
  2. Set DOWNLOADME_FILEPATH and create a file there.
  3. Enter the nHentai ID you want to download separated by linebreaks.

Example ./config/.env:

CSRFTOKEN = "your token here"
DATABASE_URL = "./db/db.sqlite"
DONTDOWNLOADME_FILEPATH = "./config/dontdownloadme.txt"
DOWNLOADME_FILEPATH = "./config/downloadme.txt"
LIBRARY_PATH = "./hentai/"
USER_AGENT = "your user agent here"

Ich mein's ernst: Keeping a Self-Hosted Library Up-to-Date

  1. Set NHENTAI_TAGS to define the tag search that you want to use to keep your library up-to-date.
  2. Set DOWNLOADME_FILEPATH but ensure there is no file actually there, otherwise it will be downloaded first.
  3. Consider setting LIBRARY_SPLIT to a value other than 0 if you plan to keep more than 10.000 files in your LIBRARY_PATH directory.
  4. Consider setting SLEEP_INTERVAL to wait a bit between searches. I recommend a value of at least 50.000.
  5. Searching by tag results in seemingly random error 404 on some pages. Let it search and download multiple times to get everything reliably.

Example ./config/.env:

CF_CLEARANCE = ""
CSRFTOKEN = "your token here"
DATABASE_URL = "./db/db.sqlite"
DONTDOWNLOADME_FILEPATH = "./config/dontdownloadme.txt"
DOWNLOADME_FILEPATH = "./config/downloadme.txt"
LIBRARY_PATH = "./hentai/"
LIBRARY_SPLIT = 10000
NHENTAI_TAGS = ['language:"english"']
SLEEP_INTERVAL = 50000
USER_AGENT = "your user agent here"

Exporting Favourites

nHentai Archivist is not connected to your nHentai account in any way. Automatically generating a downloadme.txt from your list of favourites is beyond the scope of this tool. However, once you compiled your favourites as a list of ID separated by line breaks, nHentai Archivist can take over. Other users were quick to automate this process, I have linked a few of the provided solutions:

[!CAUTION] I have not tested any of these scripts. I am linking them in good faith and rely on the feedback of the community.

Known Issues