wallhaven_sdk_go

package module
v0.0.0-...-4441cf1 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2023 License: MIT Imports: 8 Imported by: 0

README

wallhaven-sdk-go

Wallhaven implemented by go.

Documentation

Index

Constants

View Source
const (
	// Ultrawide
	R_2560x1080 Resolution = "2560x1080"
	R_3440x1440 Resolution = "3440x1440"
	R_3840x1600 Resolution = "3840x1600"

	// 16:9
	R_1280x720  = "1280x720"
	R_1600x900  = "1600x900"
	R_1920x1080 = "1920x1080"
	R_2560x1440 = "2560x1440"
	R_3840x2160 = "3840x2160"

	// 16:10
	R_1280x800  = "1280x800"
	R_1600x1000 = "1600x1000"
	R_1920x1200 = "1920x1200"
	R_2560x1600 = "2560x1600"
	R_3840x2400 = "3840x2400"

	// 4:3
	R_1280x960  = "1280x960"
	R_1600x1200 = "1600x1200"
	R_1920x1440 = "1920x1440"
	R_2560x1920 = "2560x1920"
	R_3840x2880 = "3840x2880"

	// 5:4
	R_1280x1024 = "1280x1024"
	R_1600x1280 = "1600x1280"
	R_1920x1536 = "1920x1536"
	R_2560x2048 = "2560x2048"
	R_3840x3072 = "3840x3072"
)

Variables

View Source
var (
	ErrUnknown = errors.New("unknown err")
)

Functions

func TrimSpaceAndSplit

func TrimSpaceAndSplit(str string) []string

Types

type AIArt

type AIArt bool

func (AIArt) String

func (a AIArt) String() string

type Category

type Category int32
const (
	People Category = 1 << iota
	Anime
	General
)

func (Category) String

func (c Category) String() string

type Client

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

func NewClient

func NewClient(optFs ...SetOption) *Client

func (*Client) GetCollectionWallpapers

func (c *Client) GetCollectionWallpapers(ctx context.Context, req *GetCollectionWallpapersReq) (
	*GetCollectionWallpapersRsp, error)

func (*Client) GetCollections

func (c *Client) GetCollections(ctx context.Context, req *GetCollectionsReq) (*GetCollectionsRsp, error)

func (*Client) GetSettings

func (c *Client) GetSettings(ctx context.Context) (*GetSettingsRsp, error)

func (*Client) GetTag

func (c *Client) GetTag(ctx context.Context, req *GetTagReq) (*Tag, error)

func (*Client) GetWallpaper

func (c *Client) GetWallpaper(ctx context.Context, req *GetWallpaperReq) (*Wallpaper, error)

func (*Client) Search

func (c *Client) Search(ctx context.Context, req *SearchReq) (*SearchRsp, error)

type Collection

type Collection struct {
	Id     int    `json:"id"`
	Label  string `json:"label"`
	Views  int    `json:"views"`
	Public int    `json:"public"`
	Count  int    `json:"count"`
}

type Color

type Color = string
const (
	C_660000 Color = "660000"
	C_990000 Color = "990000"
	C_cc0000 Color = "cc0000"
	C_cc3333 Color = "cc3333"
	C_ea4c88 Color = "ea4c88"
	C_993399 Color = "993399"
	C_663399 Color = "663399"
	C_333399 Color = "333399"
	C_0066cc Color = "0066cc"
	C_0099cc Color = "0099cc"
	C_66cccc Color = "66cccc"
	C_77cc33 Color = "77cc33"
	C_669900 Color = "669900"
	C_336600 Color = "336600"
	C_666600 Color = "666600"
	C_999900 Color = "999900"
	C_cccc33 Color = "cccc33"
	C_ffff00 Color = "ffff00"
	C_ffcc33 Color = "ffcc33"
	C_ff9900 Color = "ff9900"
	C_ff6600 Color = "ff6600"
	C_cc6633 Color = "cc6633"
	C_996633 Color = "996633"
	C_663300 Color = "663300"
	C_000000 Color = "000000"
	C_999999 Color = "999999"
	C_cccccc Color = "cccccc"
	C_ffffff Color = "ffffff"
	C_424153 Color = "424153"
)

type GetCollectionWallpapersReq

type GetCollectionWallpapersReq struct {
	Username string
	ID       int
}

func (*GetCollectionWallpapersReq) API

func (*GetCollectionWallpapersReq) Map

func (gcw *GetCollectionWallpapersReq) Map() map[string]string

type GetCollectionWallpapersRsp

type GetCollectionWallpapersRsp struct {
	Wallpapers []Wallpaper `json:"data"`
	Meta       Meta        `json:"meta"`
}

type GetCollectionsReq

type GetCollectionsReq struct {
	Username string
}

func (*GetCollectionsReq) API

func (gcr *GetCollectionsReq) API() string

func (*GetCollectionsReq) Map

func (gcr *GetCollectionsReq) Map() map[string]string

type GetCollectionsRsp

type GetCollectionsRsp struct {
	Collections []Collection `json:"data"`
}

type GetSettingsRsp

type GetSettingsRsp struct {
	ThumbSize     string   `json:"thumb_size"`
	PerPage       string   `json:"per_page"`
	Purity        []string `json:"purity"`
	Categories    []string `json:"categories"`
	Resolutions   []string `json:"resolutions"`
	AspectRatios  []string `json:"aspect_ratios"`
	TopListRange  string   `json:"toplist_range"`
	TagBlacklist  []string `json:"tag_blacklist"`
	UserBlacklist []string `json:"user_blacklist"`
}

type GetTagReq

type GetTagReq struct {
	ID int
}

func (*GetTagReq) API

func (gti *GetTagReq) API() string

func (*GetTagReq) Map

func (gti *GetTagReq) Map() map[string]string

type GetWallpaperReq

type GetWallpaperReq struct {
	ID string
}

func (*GetWallpaperReq) API

func (gwr *GetWallpaperReq) API() string

func (*GetWallpaperReq) Map

func (gwr *GetWallpaperReq) Map() map[string]string

type Meta

type Meta struct {
	CurrentPage int         `json:"current_page"`
	LastPage    int         `json:"last_page"`
	PerPage     int         `json:"per_page"`
	Total       int         `json:"total"`
	Query       interface{} `json:"query"`
	Seed        interface{} `json:"seed"`
}

type MetaQuery

type MetaQuery struct {
	ID  int    `json:"id"`
	Tag string `json:"tag"`
}

type Order

type Order = string
const (
	Desc Order = "desc"
	Asc  Order = "asc"
)

type Purity

type Purity int32
const (
	NSFW Purity = 1 << iota
	Sketchy
	SFW
)

func (Purity) String

func (p Purity) String() string

type Query

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

func (*Query) AddExclude

func (q *Query) AddExclude(tag string)

func (*Query) AddFuzzy

func (q *Query) AddFuzzy(tag string)

func (*Query) AddMust

func (q *Query) AddMust(tag string)

func (*Query) SetExact

func (q *Query) SetExact(tag int)

func (*Query) SetLike

func (q *Query) SetLike(like string)

func (*Query) SetType

func (q *Query) SetType(typ Type)

func (*Query) SetUsername

func (q *Query) SetUsername(username string)

func (*Query) String

func (q *Query) String() (result string)

type Ratio

type Ratio = string
const (
	Landscape Ratio = "landscape"
	Portrait  Ratio = "portrait"

	// Wide
	O_16x9  Ratio = "16x9"
	O_16x10 Ratio = "16x10"

	// Ultrawide
	O_21x9 Ratio = "21x9"
	O_32x9 Ratio = "32x9"
	O_48x9 Ratio = "48x9"

	// Portrait
	O_9x16  Ratio = "9x16"
	O_10x16 Ratio = "10x16"
	O_9x18  Ratio = "9x18"

	// Square
	O_1x1 Ratio = "1x1"
	O_3x2 Ratio = "3x2"
	O_4x3 Ratio = "4x3"
	O_5x4 Ratio = "5x4"
)

type Ratios

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

func (*Ratios) AddRatio

func (r *Ratios) AddRatio(ratios ...Ratio) *Ratios

func (*Ratios) String

func (r *Ratios) String() string

type Resolution

type Resolution = string

type Resolutions

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

func (*Resolutions) Map

func (r *Resolutions) Map() map[string]string

func (*Resolutions) SetAtLeast

func (r *Resolutions) SetAtLeast(al Resolution) *Resolutions

func (*Resolutions) SetCustom

func (r *Resolutions) SetCustom(width, height int) *Resolutions

func (*Resolutions) SetExact

func (r *Resolutions) SetExact(rs ...Resolution) *Resolutions

type SearchReq

func (*SearchReq) API

func (sr *SearchReq) API() string

func (*SearchReq) Map

func (sr *SearchReq) Map() map[string]string

type SearchRsp

type SearchRsp struct {
	Wallpapers []Wallpaper `json:"data"`
	Meta       Meta        `json:"meta"`
}

type SetOption

type SetOption func(*option)

func WithAPIKey

func WithAPIKey(apiKey string) SetOption

func WithDebug

func WithDebug(debug bool) SetOption

type Sorting

type Sorting = string
const (
	DateAdded Sorting = "date_added"
	Relevance Sorting = "relevance"
	Random    Sorting = "random"
	Views     Sorting = "views"
	Favorites Sorting = "favorites"
	TopList   Sorting = "toplist"
	Hot       Sorting = "hot"
)

type Tag

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

type Thumbs

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

type TopRange

type TopRange = string
const (
	D1 TopRange = "1d"
	D3 TopRange = "3d"
	W1 TopRange = "1w"
	M1 TopRange = "1M"
	M3 TopRange = "3M"
	M6 TopRange = "6M"
	Y1 TopRange = "1y"
)

type Type

type Type = string
const (
	PNG Type = "png"
	JPG Type = "jpg"
)

type Uploader

type Uploader struct {
	Username string            `json:"username"`
	Group    string            `json:"group"`
	Avatar   map[string]string `json:"avatar"`
}

type Wallpaper

type Wallpaper struct {
	Id         string   `json:"id"`
	Url        string   `json:"url"`
	ShortUrl   string   `json:"short_url"`
	Uploader   Uploader `json:"uploader"`
	Views      int      `json:"views"`
	Favorites  int      `json:"favorites"`
	Source     string   `json:"source"`
	Purity     string   `json:"purity"`
	Category   string   `json:"category"`
	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"`
	CreatedAt  string   `json:"created_at"`
	Colors     []string `json:"colors"`
	Path       string   `json:"path"`
	Thumbs     Thumbs   `json:"thumbs"`
	Tags       []Tag    `json:"tags"`
}

Jump to

Keyboard shortcuts

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