GoHaven

package module
v0.0.0-...-ce6b1ea Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2019 License: GPL-3.0 Imports: 13 Imported by: 4

README

GoHaven

A GoLang based API for access Wallhaven.cc


TODO

Actually make the read me

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HexToRGB

func HexToRGB(hex string) (int, int, int)

Types

type Categories

type Categories uint32

Categories specifies the enabled wallpaper categories of a search query.

const (
	CatGeneral Categories = 1 << iota
	CatAnime
	CatPeople
)

Wallpaper categories.

func (Categories) Key

func (v Categories) Key() string

Key returns the key of the search parameter.

func (*Categories) Set

func (v *Categories) Set(s string) error

Set implements the flag.Value interface. A comma-separated list of the following options is valid:

  • general
  • anime
  • people

func (Categories) String

func (v Categories) String() string

String returns a string representation of the search option.

func (Categories) Value

func (v Categories) Value() string

Value returns the value of the search parameter.

type Color

type Color struct {
	HEX  string
	RGB  string
	Link string
}

type ID

type ID int

ID represents the wallpaper ID of a specific wallpaper on wallhaven.cc.

func (ID) Details

func (id ID) Details() (details *ImageDetail, err error)

type ImageDetail

type ImageDetail struct {
	ImageID    ID
	URL        string
	UploadedOn string `json:,omitempty`
	Category   string
	Purity     string
	Views      int
	Favorites  int
	Link       string
	Uploader   Uploader
	Tags       []Tag
	Colors     []Color
}

func (*ImageDetail) Download

func (detail *ImageDetail) Download(dir string) (p string, err error)

func (*ImageDetail) GetImageBuffer

func (detail *ImageDetail) GetImageBuffer() (io.ReadCloser, error)

func (*ImageDetail) ReadAll

func (detail *ImageDetail) ReadAll() (buf []byte, err error)

type Option

type Option interface {
	// Key returns the key of the search parameter.
	Key() string
	// Value returns the value of the search parameter.
	Value() string
}

An Option represents a search option.

type Order

type Order int

Order specifies the sorting order used in search queries.

const (
	OrderAsc Order = 1 + iota
	OrderDesc
)

Sorting orders.

func (Order) Key

func (v Order) Key() string

Key returns the key of the search parameter.

func (*Order) Set

func (v *Order) Set(s string) error

Set implements the flag.Value interface. A comma-separated list of the following options is valid:

  • asc
  • desc

func (Order) String

func (v Order) String() string

String returns a string representation of the search option.

func (Order) Value

func (v Order) Value() string

Value returns the value of the search parameter.

type Page

type Page int

Page specifies the result page number.

func (Page) Key

func (v Page) Key() string

Key returns the key of the search parameter.

func (*Page) Set

func (v *Page) Set(s string) error

Set implements the flag.Value interface.

func (Page) String

func (v Page) String() string

String returns a string representation of the search option.

func (Page) Value

func (v Page) Value() string

Value returns the value of the search parameter.

type Purity

type Purity uint32

Purity specifies the enabled purity modes of a search query.

const (
	PuritySFW Purity = 1 << iota
	PuritySketchy
)

Purity modes.

func (Purity) Key

func (v Purity) Key() string

Key returns the key of the search parameter.

func (*Purity) Set

func (v *Purity) Set(s string) error

Set implements the flag.Value interface. A comma-separated list of the following options is valid:

  • SFW
  • sketchy
  • NSFW

func (Purity) String

func (v Purity) String() string

String returns a string representation of the search option.

func (Purity) Value

func (v Purity) Value() string

Value returns the value of the search parameter.

type Ratios

type Ratios uint32

Ratio specifies the enabled aspect ratios of a search query.

const (
	Ratio4x3 Ratios = 1 << iota
	Ratio5x4
	Ratio16x9
	Ratio16x10
	Ratio21x9
	Ratio32x9
	Ratio48x9
	Ratio9x16
	Ratio10x16
)

Aspect ratios.

func (Ratios) Key

func (v Ratios) Key() string

Key returns the key of the search parameter.

func (*Ratios) Set

func (v *Ratios) Set(s string) error

Set implements the flag.Value interface. A comma-separated list of the following options is valid:

  • 4x3
  • 5x4
  • 16x9
  • 16x10
  • 21x9
  • 32x9
  • 48x9

func (Ratios) String

func (v Ratios) String() string

String returns a string representation of the search option.

func (Ratios) Value

func (v Ratios) Value() string

Value returns the value of the search parameter.

type Resolutions

type Resolutions uint32

Resolutions specifies the enabled screen resolution of a search query.

const (
	Res1024x768 Resolutions = 1 << iota
	Res1280x800
	Res1366x768
	Res1280x960
	Res1440x900
	Res1600x900
	Res1280x1024
	Res1600x1200
	Res1680x1050
	Res1920x1080
	Res1920x1200
	Res2560x1440
	Res2560x1600
	Res3840x1080
	Res5760x1080
	Res3840x2160
)

Screen resolutions.

func (Resolutions) Key

func (v Resolutions) Key() string

Key returns the key of the search parameter.

func (*Resolutions) Set

func (v *Resolutions) Set(s string) error

Set implements the flag.Value interface. A comma-separated list of the following options is valid:

  • 1024x768
  • 1280x800
  • 1366x768
  • 1280x960
  • 1440x900
  • 1600x900
  • 1280x1024
  • 1600x1200
  • 1680x1050
  • 1920x1080
  • 1920x1200
  • 2560x1440
  • 2560x1600
  • 3840x1080
  • 5760x1080
  • 3840x2160

func (Resolutions) String

func (v Resolutions) String() string

String returns a string representation of the search option.

func (Resolutions) Value

func (v Resolutions) Value() string

Value returns the value of the search parameter.

type SearchInfo

type SearchInfo struct {
	CurrentPage int
	TotalPages  int
	End         bool
	Results     []SearchResult
}

type SearchResult

type SearchResult struct {
	ImageID   ID
	Thumbnail string
	Purity    string
	Category  string
	Width     int
	Height    int
	Favorites int
	Link      string
}

type Sorting

type Sorting int

Sorting specifies the sorting method used in search queries.

const (
	SortRelevance Sorting = 1 + iota
	SortRandom
	SortDateAdded
	SortViews
	SortFavorites
)

Sorting methods.

func (Sorting) Key

func (v Sorting) Key() string

Key returns the key of the search parameter.

func (*Sorting) Set

func (v *Sorting) Set(s string) error

Set implements the flag.Value interface. A comma-separated list of the following options is valid:

  • relevance
  • random
  • date_added
  • views
  • favorites

func (Sorting) String

func (v Sorting) String() string

String returns a string representation of the search option.

func (Sorting) Value

func (v Sorting) Value() string

Value returns the value of the search parameter.

type Tag

type Tag struct {
	TagID  int
	Name   string
	Purity string
	Link   string
}

type Uploader

type Uploader struct {
	Name           string
	Profile        string
	ProfilePicture string
}

type WallHaven

type WallHaven struct {
}

func New

func New() *WallHaven

func (*WallHaven) Search

func (wh *WallHaven) Search(query string, options ...Option) (result *SearchInfo, err error)

Search searches for wallpapers based on the given query and search options.

func (*WallHaven) UserUploads

func (wh *WallHaven) UserUploads(user string, options ...Option) (result *SearchInfo, err error)

Jump to

Keyboard shortcuts

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