digitalblasphemy

package
v0.0.0-...-1ba0d7e Latest Latest
Warning

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

Go to latest
Published: May 28, 2019 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidResolution happens when the requested resolution doesn't exist
	// on the website.
	ErrInvalidResolution = errors.New("invalid resolution")

	// ErrNoWallpapersFound happens when the server response is parsed successfully,
	// but no valid items are found.
	ErrNoWallpapersFound = errors.New("zero wallpapers returned from server")
)
View Source
var (
	// ErrInvalidCredentials happens when the credentials were rejected by the
	// server.
	ErrInvalidCredentials = errors.New("got unauthorized from server")
)

Functions

func FetchWallpaper

func FetchWallpaper(wallpaper Wallpaper, creds *Credentials) (string, error)

FetchWallpaper downloads the given wallpaper, optionally with the provided credentials.

func GetCachedCurrent

func GetCachedCurrent() string

GetCachedCurrent gets the current wallpaper ID from the cache.

func GetValidResolutions

func GetValidResolutions() []string

GetValidResolutions returns the list of all valid resolutions.

func IsValidResolution

func IsValidResolution(resolution string) bool

IsValidResolution checks if the given resolution is valid.

func LoadCache

func LoadCache() error

LoadCache loads the cache from disk.

func SaveCache

func SaveCache() error

SaveCache saves the cache on disk.

func SetCachedCurrent

func SetCachedCurrent(id string)

SetCachedCurrent sets the current wallpaper ID in the cache.

Types

type Credentials

type Credentials struct {
	Username string
	Password string
}

Credentials holds the username and password used to authorize in the members section of the website.

func (*Credentials) Validate

func (c *Credentials) Validate() error

Validate tries to load a page and thus verify the credentials.

type Wallpaper

type Wallpaper struct {
	ID         string
	URL        string
	Resolution string
}

Wallpaper is a single wallpaper image that can be downloaded from the website.

func GetFreebiesIndex

func GetFreebiesIndex() ([]Wallpaper, error)

GetFreebiesIndex returns the list of all wallpaper URLs that are available for free.

func GetIndex

func GetIndex(resolution string, creds *Credentials) ([]Wallpaper, error)

GetIndex returns the list of all wallpaper URLs for the given resolution.

Jump to

Keyboard shortcuts

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