Giter VIP home page Giter VIP logo

gnhentai's Introduction

gnhentai

gnhentai โ€” nhentai.net parser for Go.


Getting Started

This library is packaged using 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

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=<your_manga_id>

Use API server

gnhentai-server run --bind=<bind_addr, default is :8080> 

Related

gnhentai's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar tdakkota avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

kazuma-desu

gnhentai's Issues

Add caching to server

gnhentai-server provides Cache interface

type Cache interface {
	GetDoujinshi(bookID int) (gnhentai.Doujinshi, error)
	SetDoujinshi(bookID int, d gnhentai.Doujinshi) error

	GetPage(bookID, n int) (io.ReadCloser, error)
	SetPage(bookID int, image io.ReadCloser) error

	GetCover(bookID int) (io.ReadCloser, error)
	SetCover(bookID int, image io.ReadCloser) error

	GetThumbnail(bookID int) (io.ReadCloser, error)
	SetThumbnail(bookID int, image io.ReadCloser) error

	Search(q string) ([]gnhentai.Doujinshi, error)
	SetSearch(q string, result []gnhentai.Doujinshi) error

	SearchByTag(tag gnhentai.Tag) ([]gnhentai.Doujinshi, error)
	SetSearchByTag(tag gnhentai.Tag, result []gnhentai.Doujinshi) error

	Related(bookID int) ([]gnhentai.Doujinshi, error)
	SetRelated(bookID int, result []gnhentai.Doujinshi) error
}

You can use gokv package for example(original package does not support expiration, see this issue)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.