Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tdakkota/gnhentai

nhentai.net API Client
https://github.com/tdakkota/gnhentai

anime doujinshi hentai hentai-downloader nhentai nhentai-api nhentai-client nhentai-parser

Last synced: about 2 months ago
JSON representation

nhentai.net API Client

Awesome Lists containing this project

README

        

gnhentai

gnhentai — nhentai.net parser for Go.









---

## Getting Started

This library is packaged using [Go modules][go-modules]. You can get it via:

```
go get github.com/tdakkota/gnhentai
```

## Use as lib

There are two implementations of `gnhentai.Client`:
- `api.Client` which uses NHentai API
- `parser.Parser` which parses NHentai web pages using `goquery`

I recommend you to use API version, it is more stable.

[Example](https://github.com/tdakkota/gnhentai/tree/master/examples/download-random-cover/main.go)
```go
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)
}
}

```

## gnhentai-cli
Install and run (`GOBIN` should be in `PATH`), it will download random book into current dir

```
gnhentai-cli download
```

or

```
gnhentai-cli download --id=
```

## Use API server

```
gnhentai-server run --bind=
```

## Related

- [Swagger file](https://gist.github.com/tdakkota/6efa100de2000549027617b1a1088d78)
- [Unofficial API Docs](https://edgyboi2414.github.io/nhentai-api)

[go-modules]: https://github.com/golang/go/wiki/Modules