downloader

package
v0.0.0-...-7d4b7a9 Latest Latest
Warning

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

Go to latest
Published: May 15, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is a downloader client

func NewClient

func NewClient(ctx context.Context, baseDir string, impls []ClientImpl) (*Client, error)

NewClient creates a new client

func (*Client) Download

func (c *Client) Download(ctx context.Context, id string, furl string) (string, error)

Download downloads media into a given location

type ClientImpl

type ClientImpl interface {
	// Download downloads a file into a specific location
	Download(ctx context.Context, baseDir string, progress chan ProgressUpdate, url string) error

	// Register is used for the client, and returns what protocols / file extensions
	// this downloader supports
	Register() ClientRegister
}

ClientImpl is a downloader implementation

type ClientRegister

type ClientRegister struct {
	// Name is the name of this client, e.g. Downloade
	Name string

	// Protocols is a []string of the url.Schemes supported by this client, and will
	// trigger the invocation of the client.Download method.
	Protocols []string

	// FileExtensions is the list of file extensions supported by this downloader
	// and results in this downloader being called -- regardless of url.Scheme, however
	// this will only trigger on http[s] URLs
	FileExtensions []string
}

ClientRegister is a struct used to register a downloader implementation with a given client

type ProgressUpdate

type ProgressUpdate struct {
	URL      string
	Progress float64
}

ProgressUpdate is emitted when the progress of a download updates, this is sent from a ClientImpl to the client

Directories

Path Synopsis
Package http is a downloader implementer for downloading files from HTTP/S
Package http is a downloader implementer for downloading files from HTTP/S
Package torrent is a downloader implementer for downloading torrents
Package torrent is a downloader implementer for downloading torrents

Jump to

Keyboard shortcuts

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