hitomi

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2023 License: MIT Imports: 12 Imported by: 0

README

project logo

Build Go Report Card Go Reference GitHub

hitomi

hitomi is go client library for hitomi.la

feature status
search (Partial Support)
gallery information
retrieve image

Documentation

Index

Constants

View Source
const MaxNodeSize = 464

MaxNodeSize is the maximum size of a binary tree node, which is request chunk size.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a hitomi client

func NewClient

func NewClient(options *Options) *Client

NewClient creates a new hitomi client.

func (*Client) File

func (c *Client) File(url, galleryId string) ([]byte, error)

File returns file bytes

func (*Client) FileRequest

func (c *Client) FileRequest(url, galleryId string) *http.Request

FileRequest returns *http.Request for file useful when displaying download progress.

func (*Client) FileURL

func (c *Client) FileURL(hash string) string

FileURL returns calculated url for file returned file url is not permanent, usually it lasts 30~ minutes after gg.js updated

func (*Client) Gallery

func (c *Client) Gallery(id string) (*Gallery, error)

Gallery returns normalized gallery information.

func (*Client) UpdateScript

func (c *Client) UpdateScript() error

UpdateScript updates script from https://ltn.hitomi.la/gg.js This is required to calculate file url.

type Gallery struct {
	Language          string
	Id                string
	Blocked           bool
	Related           []string
	LanguageUrl       string
	LanguageLocalName string
	Title             string
	Date              string
	Type              string
	GalleryUrl        string
	JapaneseTitle     *string
	Languages         []struct {
		LocalName string
		GalleryId string
		Name      string
		Url       string
	}
	Tags []struct {
		Tag string
		Url string
	}
	Artists []struct {
		Artist string
		Url    string
	}
	Files []struct {
		HasJXL  bool
		HasAVIF bool
		HasWEBP bool
		Width   int
		Height  int
		Name    string
		Hash    string
		Single  bool
	}
	Characters []struct {
		Character string
		Url       string
	}
	Parodies []struct {
		Parody string
		Url    string
	}
	Groups []struct {
		Group string
		Url   string
	}
}

Gallery represents gallery information.

type Options

type Options struct {
	Client *http.Client
	Logger zerolog.Logger

	// UpdateScriptInterval is an option to update the script every interval.
	// if it is set to -1, it will never update the script.
	UpdateScriptInterval time.Duration

	// CacheWholeIndex is an option to download the whole index and cache it.
	// it can be extremely slow the first time (especially for gallery index) and consume much memory space,
	// but it will be a lot faster when you search.
	CacheWholeIndex bool
}

func DefaultOptions

func DefaultOptions() *Options

func (*Options) WithCacheWholeIndex added in v0.0.3

func (o *Options) WithCacheWholeIndex(b bool) *Options

func (*Options) WithClient

func (o *Options) WithClient(c *http.Client) *Options

func (*Options) WithLogger

func (o *Options) WithLogger(l zerolog.Logger) *Options

func (*Options) WithUpdateScriptInterval

func (o *Options) WithUpdateScriptInterval(t time.Duration) *Options
type Search struct {
	// contains filtered or unexported fields
}

Search is a hitomi search client.

func NewSearch added in v0.0.2

func NewSearch(options *Options) *Search

func (*Search) IndexVersion added in v0.0.2

func (s *Search) IndexVersion(name string) (string, error)

IndexVersion returns the version of the index.

func (*Search) TagSuggestion added in v0.0.3

func (s *Search) TagSuggestion(query string) ([]string, error)

TagSuggestion returns tag suggestions for the query. The query must be in the form of "field:query".

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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