Documentation
¶
Index ¶
- type Options
- func (o *Options) SetBasicAuth(username, password string)
- func (o *Options) SetBearerToken(token string)
- func (o *Options) SetCustomFilename(url, filename string)
- func (o *Options) SetExpectedChecksum(url, checksum string)
- func (o *Options) SetOutput(p string)
- func (o *Options) SetParallel(i int)
- func (o *Options) SetTitle(t string) error
- func (o *Options) SetURLs(u []string)
- func (o *Options) Start() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct {
// Headers is the headers to be sent with the request
Headers map[string]string
// Retry is the number of times the request should be retried
// If not provided, 3 will be used
Retry int
// ShowProgress is the flag to show the progress of the download
// If not provided, false will be used
ShowProgress bool
// DownloadPath is the path to download the files
// If not provided, the current directory will be used
DownloadPath string
// Parallel is the number of parallel downloads
// If not provided, 1 will be used
Parallel int
// Timeout is the time to wait for the download
// If not provided, 10 seconds will be used
Timeout int
// Title is the title of the download folder
// If not provided, the title will be empty
// If a URL is provided, it will try to get the title from the URL webpage, if not, the domain name will be used.
Title string
// Log is the logger to be used
Log *log.Logger
// ResumeDownload is the flag to enable resuming interrupted downloads
// If not provided, false will be used
ResumeDownload bool
// BandwidthLimit is the maximum download speed in KB/s
// If not provided or set to 0, no limit will be applied
BandwidthLimit int
// CustomFilenames is a map of URL to custom filename
// If provided, the custom filename will be used instead of the one from the URL
CustomFilenames map[string]string
// VerifyChecksum is the flag to enable checksum verification
// If not provided, false will be used
VerifyChecksum bool
// ExpectedChecksums is a map of URL to expected checksum
// The format is "algorithm:checksum", e.g. "sha256:1234abcd..."
// Supported algorithms: md5, sha1, sha256
ExpectedChecksums map[string]string
// contains filtered or unexported fields
}
func NewDownload ¶
NewDownload creates a new download with some default options
func (*Options) SetBasicAuth ¶
SetBasicAuth sets the basic authentication header
func (*Options) SetBearerToken ¶
SetBearerToken sets the bearer token authentication header
func (*Options) SetCustomFilename ¶
SetCustomFilename sets a custom filename for a URL
func (*Options) SetExpectedChecksum ¶
SetExpectedChecksum sets the expected checksum for a URL The format is "algorithm:checksum", e.g. "sha256:1234abcd..." Supported algorithms: md5, sha1, sha256
func (*Options) SetParallel ¶
SetParallel sets the number of parallel downloads. Default is 1
func (*Options) SetTitle ¶
SetTitle sets the title of the download If a URL is provided, it will try to get the title from the URL webpage, if not, the domain name will be used.
Click to show internal directories.
Click to hide internal directories.