lib

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2017 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const NOOFIMAGES = 5

NOOFIMAGES denotes the number of images to be downloaded per Website URL.

Variables

View Source
var ConfigPath = filepath.Join(GetUserHomeDir(), ".uipgo.json")

ConfigPath contains the path for uipgo configuration.

Functions

func Check

func Check(e error)

Check logs any errors occured when an error is passed.

func DownloadFile

func DownloadFile(
	path string, rawurl string, bar *uiprogress.Bar, wg *sync.WaitGroup,
)

DownloadFile downloads a file from the given url and stores it in filepath

func FetchConfig added in v0.0.3

func FetchConfig(ctx *cli.Context, conf *Settings)

FetchConfig retrieves intial configuration into the Settings object.

func GetAndStoreImages

func GetAndStoreImages(sites map[string][]string, directory string)

GetAndStoreImages downloads and stores images from given websites.

func GetUserHomeDir added in v0.0.3

func GetUserHomeDir() string

GetUserHomeDir returns the current user's home directory.

func ShowDownloadProgress added in v0.0.3

func ShowDownloadProgress(
	done chan int64, bar *uiprogress.Bar, path string, total int64,
)

ShowDownloadProgress shows the download progress through the bar provided.

Types

type DesktopprAPIResponse

type DesktopprAPIResponse struct {
	Images []DesktopprImage `json:"response"`
}

DesktopprAPIResponse represents a list of DesktopprImages from the API response on https://api.desktoppr.co

type DesktopprImage

type DesktopprImage struct {
	Image DesktopprResponseURL `json:"image"`
}

DesktopprImage represents an image on https://desktoppr.co

func (DesktopprImage) Name

func (i DesktopprImage) Name() string

Name retrieves the name of DesktopprImage

func (DesktopprImage) URL

func (i DesktopprImage) URL() string

URL retrieves the url of DesktopprImage

type DesktopprResponseURL

type DesktopprResponseURL struct {
	URL string `json:"url"`
}

DesktopprResponseURL contains the actual URL field for DesktopprImage

type Image

type Image interface {
	URL() string
	Name() string
}

Image is a golang representation for image metadata.

func GetDesktopprImages

func GetDesktopprImages(rawurl string, wg *sync.WaitGroup) []Image

GetDesktopprImages gets a list of images from provided Desktoppr API endpoint.

func GetUnsplashImages

func GetUnsplashImages(rawurl string, wg *sync.WaitGroup) []Image

GetUnsplashImages gets a list of images from provided Unsplash API endpoint.

type Settings added in v0.0.3

type Settings struct {
	StoragePath string `json:"storage_path"`
}

Settings contains the configuration for uipgo.

func (*Settings) Fetch added in v0.0.3

func (s *Settings) Fetch() (*Settings, error)

Fetch retrieves the configuration for uipgo.

func (*Settings) Store added in v0.0.3

func (s *Settings) Store() (*Settings, error)

Store sets the configuration for uipgo.

type UnsplashImage

type UnsplashImage struct {
	URLs map[string]string `json:"urls"`
}

UnsplashImage represents an image from https://unsplash.com

func (UnsplashImage) Name

func (i UnsplashImage) Name() string

Name retrieves the name of UnsplashImage

func (UnsplashImage) URL

func (i UnsplashImage) URL() string

URL retrieves the url of UnsplashImage

Jump to

Keyboard shortcuts

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