unsplash

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const AuthFile = ".unsplash.yaml"

Variables

This section is empty.

Functions

This section is empty.

Types

type Auth

type Auth struct {
	AccessKey string `yaml:"access_key"`
}

Auth is the structure of the Source authentication file.

func LoadAuth

func LoadAuth(path string) (*Auth, error)

loadUnsplashAuth loads the Source authentication file.

type Source

type Source struct {
	Client *unsplash.Unsplash
}

Source sources photos from unsplash.com.

func New

func New(
	ctx context.Context,
	auth *Auth,
) *Source

func NewFromAuthFile

func NewFromAuthFile(
	ctx context.Context,
	path string,
) (*Source, error)

func NewFromEnvironment

func NewFromEnvironment(ctx context.Context) (*Source, error)

func (*Source) CacheKey

func (u *Source) CacheKey(photoUrl string) (string, bool)

CacheKey returns the cache key for a given photo URL.

func (*Source) Download

func (u *Source) Download(
	ctx context.Context,
	info *photo.Info,
) error

Download fetches the photo for the photo info.

func (*Source) Photo

func (u *Source) Photo(
	ctx context.Context,
	photoUrl string,
) (*photo.Info, error)

Photo returns the photo info for a given photo URL.

Jump to

Keyboard shortcuts

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