boorufetch

package module
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2022 License: LGPL-3.0 Imports: 14 Imported by: 6

README

GoDoc Build Status

boorufetch

provides a unified interface for fetching posts from Gelbooru and Danbooru

Documentation

Index

Constants

View Source
const FetcherCount = 4

Number of parallel fetch workers

Variables

This section is empty.

Functions

func DecodeMD5

func DecodeMD5(s string) (buf [16]byte, err error)

Decode hex string to MD5 hash

func GelbooruFetchPage

func GelbooruFetchPage(query string, json bool, page, limit uint) (
	body io.ReadCloser, err error,
)

Makes request to a gelbooru page with selected tag query

Types

type ErrUnknownRating

type ErrUnknownRating []byte

func (ErrUnknownRating) Error

func (e ErrUnknownRating) Error() string

type Post

type Post interface {
	// Return explicitness rating
	Rating() (Rating, error)

	// Return MD5 hash
	MD5() ([16]byte, error)

	// Return source file URL
	FileURL() string

	// Return sample file image URL or source file URL, if no sample present
	SampleURL() string

	// Return source URL, if any
	SourceURL() string

	// Return source file width
	Width() uint64

	// Return source file height
	Height() uint64

	// Return tags applied to post
	Tags() ([]Tag, error)

	// Return last modification date
	UpdatedOn() (time.Time, error)

	// Return post creation date
	CreatedOn() (time.Time, error)
}

Single booru image post. Fields are lazily fetched and/or converted on demand for optimization purposes.

func DanbooruByMD5

func DanbooruByMD5(md5 [16]byte) (Post, error)

Fetch a single danbooru post by MD5. If no match found, Post will be nil.

func FromDanbooru

func FromDanbooru(query string, page, limit uint) (posts []Post, err error)

Fetch posts from Danbooru for the given tag query. Note the query may only contain up to 2 tags. Fetches are limited to a maximum of FetcherCount concurrent requests to prevent antispam measures by the boorus.

func FromGelbooru

func FromGelbooru(query string, page, limit uint) (posts []Post, err error)

Fetch posts from Gelbooru for the given tag query. If the source of the image is Danbooru, a more up-to-date set of tags is fetched from there. Fetches are limited to a maximum of FetcherCount concurrent requests to prevent antispam measures by the boorus.

type Rating

type Rating uint8

Explicitness rating of post

const (
	General Rating = iota
	Questionable
	Explicit
	Sensitive
)

func (Rating) MarshalJSON

func (r Rating) MarshalJSON() ([]byte, error)

func (Rating) String

func (r Rating) String() string

func (*Rating) UnmarshalJSON

func (r *Rating) UnmarshalJSON(buf []byte) error

type Tag

type Tag struct {
	Type TagType `json:"type"`
	Tag  string  `json:"tag"`
}

Tag associated to a post

type TagType

type TagType uint8

Tag category

const (
	Undefined TagType = iota
	Author
	Character
	Series
	Meta
)

Jump to

Keyboard shortcuts

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