Documentation
¶
Index ¶
- Constants
- func GetFileNameFromUrl(imageUrl string) (string, error)
- func GetRootUrl(u string) (string, error)
- func IsUrlValid(rawUrl string) bool
- func ProcessLinks(url string, rawLinks []string) []string
- func RandomInt(min, max int) int
- func RemoveDuplicates(original []string) []string
- func Run(links []string, parameters *Parameters, httpClient HttpClient, ...) error
- type DefaultFileSystem
- type DefaultHttpClient
- type DownloadInput
- type DownloadResult
- type FileSystem
- type HttpClient
- type JsonPrinter
- type OutputFormat
- type Parameters
- type PlainTextPrinter
- type Printer
- type Sleeper
Constants ¶
View Source
const DefaultPath = "."
View Source
const DefaultReferer = "https://www.google.com"
View Source
const Timeout = 15 * time.Second
Variables ¶
This section is empty.
Functions ¶
func GetFileNameFromUrl ¶
func GetRootUrl ¶
func IsUrlValid ¶
func ProcessLinks ¶
func RemoveDuplicates ¶
func Run ¶
func Run(links []string, parameters *Parameters, httpClient HttpClient, fileSystem FileSystem) error
Types ¶
type DefaultFileSystem ¶
type DefaultFileSystem struct{}
func (*DefaultFileSystem) CreateDirectory ¶
func (f *DefaultFileSystem) CreateDirectory(directory string) error
func (*DefaultFileSystem) Exists ¶
func (f *DefaultFileSystem) Exists(path string) bool
func (*DefaultFileSystem) ReadLines ¶
func (f *DefaultFileSystem) ReadLines(path string) ([]string, error)
func (*DefaultFileSystem) Save ¶
func (f *DefaultFileSystem) Save(body io.ReadCloser, path string) error
type DefaultHttpClient ¶
type DefaultHttpClient struct {
// contains filtered or unexported fields
}
type DownloadInput ¶
func PrepareLinksForDownload ¶
func PrepareLinksForDownload(links []string, parameters *Parameters) []DownloadInput
type DownloadResult ¶
func DownloadImages ¶
func DownloadImages(links []DownloadInput, httClient HttpClient, fileSystem FileSystem, parameters *Parameters) []DownloadResult
type FileSystem ¶
type FileSystem interface { CreateDirectory(directory string) error Save(body io.ReadCloser, path string) error ReadLines(path string) ([]string, error) Exists(path string) bool }
func NewFileSystem ¶
func NewFileSystem() FileSystem
type HttpClient ¶
type HttpClient interface {
Request(url string, headers map[string]string) (*http.Response, error)
}
func NewHttpClient ¶
func NewHttpClient(userAgent string) HttpClient
type JsonPrinter ¶
type JsonPrinter struct {
// contains filtered or unexported fields
}
func (*JsonPrinter) PrintProgress ¶
func (p *JsonPrinter) PrintProgress(validLinks int)
func (*JsonPrinter) PrintResults ¶
func (p *JsonPrinter) PrintResults(results []DownloadResult)
type OutputFormat ¶
type OutputFormat string
const ( PlainText OutputFormat = "plain" Json OutputFormat = "json" )
type Parameters ¶
type PlainTextPrinter ¶
type PlainTextPrinter struct {
// contains filtered or unexported fields
}
func (*PlainTextPrinter) PrintProgress ¶
func (p *PlainTextPrinter) PrintProgress(validLinks int)
func (*PlainTextPrinter) PrintResults ¶
func (p *PlainTextPrinter) PrintResults(results []DownloadResult)
type Printer ¶
type Printer interface { PrintResults(results []DownloadResult) PrintProgress(validLinks int) }
func NewStdoutPrinter ¶
func NewStdoutPrinter(outputFormat OutputFormat) Printer
Click to show internal directories.
Click to hide internal directories.