wallhaven

package
v0.0.0-...-c7b4ba4 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2021 License: Unlicense Imports: 10 Imported by: 0

README

wallhaven

The wallhaven package implements an unofficial API for wallhaven.cc.

Documentation

Documentation provided by GoDoc.

  • wallhaven: implements search and download functionality for wallhaven.cc.

walls

walls is a tool which downloads wallpapers from wallhaven.cc.

It performs a search for wallpapers on wallbase.cc based on the given search query and search options.

For persistent storage, a custom download directory may be specified.

Installation

go get github.com/mewmew/playground/archive/wallhaven/cmd/walls

Usage

walls [OPTION]... QUERY

Flags:

-cats value
	Wallpaper categories (general,anime,people)
-n int
	Download at most n wallpapers (0 = infinite)
-o string
	Output directory (default "/tmp/walls")
-order value
	Sorting order (asc,desc)
-page value
	Result page number
-purity value
	Purity modes (SFW,sketchy,NSFW)
-ratios value
	Aspect ratios (4x3,5x4,16x9,16x10,21x9,32x9,48x9)
-res value
	Screen resolutions (1024x768,1280x800,1366x768,1280x960,1440x900,1600x900,1280x1024,1600x1200,1680x1050,1920x1080,1920x1200,2560x1440,2560x1600,3840x1080,5760x1080,3840x2160)
-sorting value
	Sorting method (relevance,random,date_added,views,favorites)

Examples

  1. Download a random wallpaper and set it as desktop background.

     walls -n 1 -sorting random | xargs -I {} feh --bg-fill "{}"
    
  2. Download wallpapers matching the search query nature to the download/ directory.

     walls -o download/ nature
    
  3. Download at most 100 SFW wallpapers with a screen resolution 1920x1080.

     wallbase -n 100 -purity SFW -res 1920x1080
    

Public domain

The source code and any original content of this repository is hereby released into the public domain.

Documentation

Overview

Package wallhaven implements search and download functionality for wallhaven.cc.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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 ID

type ID string

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

func Search(query string, options ...Option) (ids []ID, err error)

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

func (ID) Download

func (id ID) Download(dir string) (path string, err error)

Download downloads the wallpaper to the given directory, and returns the path to the downloaded file.

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
	PurityNSFW
)

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
)

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 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.

Directories

Path Synopsis
cmd
walls
walls is a tool which downloads wallpapers from wallhaven.cc.
walls is a tool which downloads wallpapers from wallhaven.cc.

Jump to

Keyboard shortcuts

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