api

package
v0.0.0-...-f207d30 Latest Latest
Warning

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

Go to latest
Published: May 18, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CategoryGeneral = "general"
	CategoryAnime   = "anime"
	CategoryPeople  = "people"
	PuritySFW       = "sfw"
	PuritySketchy   = "sketchy"
	PurityNSFW      = "nsfw"
	SortDate        = "date_added"
	SortRelevance   = "relevance"
	SortRandom      = "random"
	SortViews       = "views"
	SortFavorites   = "favorites"
	SortTopList     = "toplist"
	Range1day       = 24 * time.Hour
	Range3day       = 3 * Range1day
	Range1week      = 7 * Range1day
	Range1month     = 30 * Range1day
	Range3months    = 3 * Range1month
	Range6months    = 6 * Range1month
	Range1year      = 12 * Range1month
	RatioLandscape  = "landscape"
	RatioPortrait   = "portrait"
	ThumbSmall      = "small"
	ThumbLarge      = "large"
	ThumbOriginal   = "original"
)

Variables

View Source
var (
	ErrUnknown = errors.New("unknown error")
	ErrServer  = errors.New("server error")
)
View Source
var (
	ErrNoSuchItems = errors.New("no such items")
	ErrNoMoreItems = errors.New("no more items")
)

Functions

func PickLoop

func PickLoop(qr *QueryResult)

func PickRand

func PickRand(qr *QueryResult)

Types

type API

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

func New

func New(key string) *API

func (*API) Query

func (s *API) Query(qc *QueryCond) (*QueryResult, error)

func (*API) SetDebug

func (s *API) SetDebug()

func (*API) SetLogger

func (s *API) SetLogger(l *zap.Logger)

type PickOption

type PickOption = func(qr *QueryResult)

type QueryCond

type QueryCond struct {
	Query       string
	Categories  string `validate:"oneof=000 001 010 011 100 101 110 111"`
	Purity      string `validate:"oneof=000 001 010 011 100 101 110 111"`
	Sorting     string `validate:"oneof=date_added relevance random views favorites toplist hot"`
	Order       string `validate:"oneof=desc asc"`
	TopRange    string `validate:"oneof=1d 3d 1w 1M 3M 6M 1y"`
	AtLeast     string
	Resolutions string
	Ratios      string
	Colors      string
	Seed        string
	Page        int
}

func NewQuery

func NewQuery(q string) *QueryCond

func (*QueryCond) Asc

func (qc *QueryCond) Asc() *QueryCond

func (*QueryCond) Desc

func (qc *QueryCond) Desc() *QueryCond

func (*QueryCond) Random

func (qc *QueryCond) Random() *QueryCond

func (*QueryCond) SetCategory

func (qc *QueryCond) SetCategory(qs ...string) *QueryCond

func (*QueryCond) SetPurity

func (qc *QueryCond) SetPurity(qs ...string) *QueryCond

func (*QueryCond) SetRatio

func (qc *QueryCond) SetRatio(q string) *QueryCond

func (*QueryCond) SortBy

func (qc *QueryCond) SortBy(q string) *QueryCond

func (*QueryCond) ToMap

func (qc *QueryCond) ToMap() (map[string]string, error)

func (*QueryCond) TopList

func (qc *QueryCond) TopList(timeRange time.Duration) *QueryCond

type QueryResult

type QueryResult struct {
	RateLimitQuota  int
	RateLimitRemain int

	Data []*Wallpaper `json:"data"`
	Meta struct {
		CurrentPage int `json:"current_page"`
		LastPage    int `json:"last_page"`
		Total       int `json:"total"`
	} `json:"meta"`
	// contains filtered or unexported fields
}

func (*QueryResult) Index

func (qr *QueryResult) Index() int

func (*QueryResult) Pick

func (qr *QueryResult) Pick(opts ...PickOption) (*Wallpaper, error)

type Tag

type Tag struct {
	Id        int    `json:"id"`
	Name      string `json:"name"`
	Alias     string `json:"alias"`
	Category  string `json:"category"`
	Purity    string `json:"purity"`
	CreatedAt string `json:"created_at"`
}

type Thumbs

type Thumbs struct {
	Small    string `json:"small"`
	Large    string `json:"large"`
	Original string `json:"original"`
}

type Uploader

type Uploader struct {
	Username string `json:"username"`
	Group    string `json:"group"`
}

type Wallpaper

type Wallpaper struct {
	Id         string   `json:"id"`
	Url        string   `json:"url"`
	ShortUrl   string   `json:"short_url"`
	Source     string   `json:"source"`
	Uploader   Uploader `json:"uploader"`
	Views      int      `json:"views"`
	Favorites  int      `json:"favorites"`
	Category   string   `json:"category"`
	Purity     string   `json:"purity"`
	DimensionX int      `json:"dimension_x"`
	DimensionY int      `json:"dimension_y"`
	Resolution string   `json:"resolution"`
	Ratio      string   `json:"ratio"`
	FileSize   int      `json:"file_size"`
	FileType   string   `json:"file_type"`
	Path       string   `json:"path"`
	Colors     []string `json:"colors"`
	Thumbs     Thumbs   `json:"thumbs"`
	Tags       []Tag    `json:"tags"`
	CreatedAt  string   `json:"created_at"`
}

Jump to

Keyboard shortcuts

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