Documentation ¶
Index ¶
- Constants
- func RegisterProvider(p Provider) error
- type Account
- type Accountant
- type Client
- func (d *Client) AddURLs(urls []*url.URL) Container
- func (d *Client) DryRun()
- func (d *Client) Finalize()
- func (d *Client) OnDeadend(f func(*url.URL))
- func (d *Client) OnDownload(f func(*Download))
- func (d *Client) OnError(f func(File, error))
- func (d *Client) OnResolve(f func(*url.URL, File, error))
- func (d *Client) OnSkip(f func(File))
- func (d *Client) Resolve()
- func (d *Client) Start()
- func (d *Client) Stop()
- func (d *Client) Use(acc Account)
- type Config
- type Configured
- type Container
- type ContainerID
- type Download
- type Field
- type File
- type MultiResolver
- type Progress
- type Prompter
- type Provider
- type Providers
- type Queue
- type ReadProgress
- type Retriever
- type SingleResolver
Constants ¶
const Version = "0.3.0"
Version is the version of this library
Variables ¶
This section is empty.
Functions ¶
func RegisterProvider ¶
RegisterProvider is not thread-safe!!!!
Types ¶
type Account ¶
Account represents a persistent record on a provider (useful e.g. to access restricted files)
func TryTemplate ¶
TryTemplate creates a new account template for the given provider and returns that -- if provider implements `Accountant` interface. Otherwise, simply `nil` is returned
type Accountant ¶
type Accountant = api.Accountant
Accountant is a provider that stores user accounts
type Client ¶
type Client struct { Directory string NoSkip bool NoContinue bool Providers Providers Accounts map[string][]Account ResolvedQueue *queue // contains filtered or unexported fields }
Client manages downloads
func NewClient ¶
func NewClient() *Client
NewClient creates a new Client with 3 retrievers and 1 resolver
func NewClientWith ¶
NewClientWith creates a new Client with the amount of workers provided. If amount is 0, the Client works in resolve-only mode.
func (*Client) AddURLs ¶
AddURLs adds a list of URLs to the download queue. Returns a WaitGroup for when the downloads are complete.
func (*Client) DryRun ¶
func (d *Client) DryRun()
DryRun starts this downloader in dryrun mode, printing to stdout instead of downloading.
func (*Client) OnDownload ¶
OnDownload calls the given hook when a new Download is started. The download object is passed.
func (*Client) OnResolve ¶
OnResolve calls the given hook when a resolve job is finished. It passes the original URLs, the File if successful or the error if not.
type Configured ¶
type Configured = api.Configured
Configured are providers that require some kind of configuration/initialization
type Container ¶
type Container interface { ID() ContainerID Wait() }
Container combines URLs that were added in the same context
type ContainerID ¶
ContainerID calculates the sha256 sum of the underlying URLs
func (ContainerID) String ¶
func (urls ContainerID) String() string
type Download ¶
Download is an object that fetches a single remote file and presents information on its progress and status
func (*Download) Canceled ¶
Canceled returns whether this download was canceled. Panics if download is still running.
func (*Download) Err ¶
Err returns the error during this download if there was one. Panics if download is still running.
type File ¶
type File interface { api.File // Err returns the error associated with this file, if there is any. // // Read the note on call order in the interface description.. Err() error // Offline returns whether this file is offline. // // Read the note on call order in the interface description. Offline() bool // LengthUnknown returns whether this file's length is known // e.g. HEAD request without Content-Length. LengthUnknown() bool // ID returns the identifier for this file (sha256-sum of the URL string) ID() string // OriginalURL returns the original URL (passed to Client) that ultimately yielded this File. OriginalURL() *url.URL // contains filtered or unexported methods }
File denotes a remote file object
For any given File, the order of method calls must be:
- `Err()` - if this returns `nil`, continue with checking the file's availability:
- `Offline()` - and if this also returns false, the file is valid and available.
If `Err()` returns an error, `Offline()` and all non-URL methods will panic. Same for when `Offline()` returns `true`.
type MultiResolver ¶
type MultiResolver = api.MultiResolver
MultiResolver is a provider which can resolve multiple URLs at once
type Providers ¶
type Providers []Provider
Providers represents an array of providers with some utility functions
func RegisteredProviders ¶
func RegisteredProviders() Providers
RegisteredProviders returns a list of registered providers
func (Providers) FindProvider ¶
FindProvider searches providers (in order). Returns the first to satisfy the predicate
func (Providers) GetProvider ¶
GetProvider returns the provider for the given string, or `nil` if there was none.
type ReadProgress ¶
ReadProgress is an io.ReadCloser that tracks progress
type SingleResolver ¶
type SingleResolver = api.SingleResolver
SingleResolver is a provider which can only resolve URLs one by one