downloader

package
v0.0.21 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2023 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UserAgent               = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"
	Accept                  = "" /* 135-byte string literal not displayed */
	AcceptEncoding          = "gzip, deflate, br"
	AcceptLanguage          = "en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7"
	SecChUA                 = "\"Google Chrome\";v=\"111\", \"Not(A:Brand\";v=\"8\", \"Chromium\";v=\"111\""
	SecChUAMobile           = "?0"
	SecFetchDest            = "document"
	SecFetchMode            = "navigate"
	SecFetchSite            = "none"
	SecFetchUser            = "?1"
	UpgradeInsecureRequests = "1"
)
View Source
const (
	DeepRed    = "\x1b[38;5;196m"
	Red        = "\x1b[38;5;197m"
	Green      = "\x1b[38;5;106m"
	DeepYellow = "\x1b[38;5;178m"
	Blue       = "\x1b[38;5;67m"
	Purple     = "\x1b[38;5;133m"
	Grey       = "\x1b[38;5;243m"
	White      = "\x1b[38;5;251m"
)
View Source
const (
	BarModeDownload = "Download"
	BarModeCancel   = "Cancel"
	BarModeFailed   = "Failed"
	BarModeSuccess  = "Success"
)

Variables

This section is empty.

Functions

func AddProxy added in v0.0.10

func AddProxy(proxyUrlStr string, transport *http.Transport)

func DirectoryName

func DirectoryName(p kemono.Post) string

func NewDownloader

func NewDownloader(options ...DownloadOption) kemono.Downloader

func NewProgressBar added in v0.0.6

func NewProgressBar(content string, max int64, length int) *progressBar

Types

type DownloadOption

type DownloadOption func(*downloader)

func Async

func Async(async bool) DownloadOption

Async set the async download option

func BaseURL

func BaseURL(baseURL string) DownloadOption

BaseURL set the base url

func MaxConcurrent

func MaxConcurrent(maxConcurrent int) DownloadOption

MaxConcurrent set the max concurrent download

func MaxSize added in v0.0.2

func MaxSize(maxSize int64) DownloadOption

MaxSize set the max size of the file to download

func MinSize added in v0.0.2

func MinSize(minSize int64) DownloadOption

MinSize set the min size of the file to download

func OverWrite

func OverWrite(overwrite bool) DownloadOption

OverWrite set the overwrite option

func RateLimit

func RateLimit(n int) DownloadOption

RateLimit limit the rate of download per second

func Retry

func Retry(retry int) DownloadOption

func RetryInterval

func RetryInterval(interval time.Duration) DownloadOption

func SavePath

func SavePath(savePath func(creator kemono.Creator, post kemono.Post, i int, attachment kemono.File) string) DownloadOption

func SetLog

func SetLog(log Log) DownloadOption

SetLog set the log

func Timeout

func Timeout(timeout time.Duration) DownloadOption

Timeout set the timeout

func WithContent added in v0.0.10

func WithContent(content bool) DownloadOption

func WithCookie added in v0.0.8

func WithCookie(cookies []*http.Cookie) DownloadOption

func WithHeader

func WithHeader(header Header) DownloadOption

func WithProxy added in v0.0.7

func WithProxy(proxy string) DownloadOption
type Header map[string]string

type Log

type Log interface {
	Printf(format string, v ...interface{})
	Print(s string)
	SetStatus(s []string)
}

type Progress added in v0.0.6

type Progress struct {
	// contains filtered or unexported fields
}

func NewProgress added in v0.0.6

func NewProgress(log Log) *Progress

func (*Progress) AddBar added in v0.0.6

func (p *Progress) AddBar(bar *progressBar)

func (*Progress) Cancel added in v0.0.6

func (p *Progress) Cancel(bar *progressBar, err string)

func (*Progress) Failed added in v0.0.6

func (p *Progress) Failed(bar *progressBar, err error)

func (*Progress) Print added in v0.0.6

func (p *Progress) Print(s string)

func (*Progress) Remove added in v0.0.6

func (p *Progress) Remove(bar *progressBar)

func (*Progress) Run added in v0.0.6

func (p *Progress) Run(interval time.Duration)

func (*Progress) SetStatus added in v0.0.6

func (p *Progress) SetStatus()

func (*Progress) Success added in v0.0.6

func (p *Progress) Success(bar *progressBar)

Jump to

Keyboard shortcuts

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