hentai2gif

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 7, 2021 License: MIT Imports: 18 Imported by: 0

README

hentai2gif

A simple library to convert nhentai IDs to gif

Currently implemented:

  • Download galleries from nhentai by ID
  • Convert galleries to gif

Sample Code

Download hentai by ID and convert it to gif

package main

import "github.com/w4rryn/hentai2gif"

func main() {
	h, _ := hentai2gif.NewHentaiByID(267604)            // create hentai object with given id
	hentai2gif.ConvertHentaiToGif(h, "test.gif", 150)   // convert images in h to gif with 150ms delay between frames
}

Download hentai by ID and save images to disk

package main

import "github.com/w4rryn/hentai2gif"

func main() {
	h, _ := hentai2gif.NewHentaiByID(267604)  // create hentai object with given id          
	hentai2gif.Download(h, "hentai")          // save images to directory "hentai"
}

Limitations

This repository does not use official APIs which is why downloads may take very long since the maximum requests per second are limited. There may be a workaround to this problem if you send specific cookies with all requests like this project does: https://github.com/RicterZ/nhentai. However i wasn't able to get this to work. If you have a solution to this problem feel free to create a pull request.

Converting all images to gif is very slow probably because of color space conversion from jpg or png to gif.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertFilesToGif

func ConvertFilesToGif(files []string, fps int, p string) error

ConvertFilesToGif converts files to a gif with fps as animation duration per frame and exports it to p

func ConvertHentaiToGif

func ConvertHentaiToGif(h *Hentai, p string, d int) error

ConvertHentaiToGif converts h to gif with d as animation delay and exports it to p

func Download

func Download(h *Hentai, dir string) error

Download takes h and downloads the images in the gallery to dir

Types

type Hentai

type Hentai struct {
	//ID is the source number from nhentai
	ID int `json:"id"`
	//Title is the name of the hentai
	Title string `json:"title"`
	//Pages contains the urls to all images in the gallery
	Pages []string `json:"pages"`
}

Hentai contains the most important data for a hentai gallery

func NewHentaiByID added in v1.0.0

func NewHentaiByID(id int) (*Hentai, error)

NewHentaiByID takes hentai id and returns a Hentai instance

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL