gnhentai — nhentai.net parser for Go.
This library is packaged using Go modules. You can get it via:
go get github.com/tdakkota/gnhentai
There are two implementations of gnhentai.Client
:
api.Client
which uses NHentai APIparser.Parser
which parses NHentai web pages usinggoquery
I recommend you to use API version, it is more stable.
package main
import (
"fmt"
"github.com/tdakkota/gnhentai"
"github.com/tdakkota/gnhentai/api"
"io"
"os"
)
func main() {
c := api.NewClient()
doujinshi, err := c.Random()
if err != nil {
panic(err)
}
fmt.Println("Downloading", doujinshi.Name())
fmt.Println("Tags:")
for _, tag := range doujinshi.Tags {
fmt.Println(" - ", tag.Name)
}
format := gnhentai.FormatFromImage(doujinshi.Images.Cover)
cover, err := c.Cover(doujinshi.MediaID, format)
if err != nil {
panic(err)
}
f, err := os.Create(fmt.Sprintf("cover_%d.%s", doujinshi.MediaID, format))
if err != nil {
panic(err)
}
_, err = io.Copy(f, cover)
if err != nil {
panic(err)
}
}
Install and run (GOBIN
should be in PATH
), it will download random book into current dir
gnhentai-cli download
or
gnhentai-cli download --id=<your_manga_id>
gnhentai-server run --bind=<bind_addr, default is :8080>