client

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2024 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const DOWNLOAD_LIST_DEFAULT_MSG_WIDTH = 40
View Source
const DOWNLOAD_LIST_FORMAT = "%-16s  %-12s  %-7s  %-*s  %-s\n"

"Id", "Status", "Size", msgWidth, "Msg", "Path"

Variables

View Source
var (
	ErrFileExists = fmt.Errorf("local file exists")
)

Functions

func MatchDownloadWitchFilter

func MatchDownloadWitchFilter(download Download, filter string) bool

func PrintDownload

func PrintDownload(output io.Writer, d Download, msgWidth int)

func PrintDownloadListHeader

func PrintDownloadListHeader(output io.Writer, msgWidth int)

func PrintStatus

func PrintStatus(output io.Writer, clientInstance Client, s Status)

func Register

func Register(regInfo *RegInfo)

func Sep

func Sep(client Client) string

Types

type BaseDownloadTask

type BaseDownloadTask struct {
	Url      string
	Filename string
	SavePath string
	Paused   bool
}

func (*BaseDownloadTask) GetFilename

func (b *BaseDownloadTask) GetFilename() string

func (*BaseDownloadTask) GetPaused

func (b *BaseDownloadTask) GetPaused() bool

func (*BaseDownloadTask) GetSavePath

func (b *BaseDownloadTask) GetSavePath() string

func (*BaseDownloadTask) GetUrl

func (b *BaseDownloadTask) GetUrl() string

type Client

type Client interface {
	GetStatus() (Status, error)
	GetConfig() *config.ClientConfig
	Add(DownloadTask) (id string, err error) // Return created download id
	Get(id string) (download Download, err error)
	Delete(id string) error
	Pause(id string) error
	Resume(id string) error // Note it will throw an error if task state is "error"
	GetAll() (Downloads, error)
	ChangeUrl(id string, url string) error
}

Modeled after aria2 APIs. Notable, there is no way to resume an error task, the only choice is to re-create a new one. Currently, only http / ftp tasks is supported (a task has only one (1) file)

func CreateClient

func CreateClient(name string) (Client, error)

func CreateClientInternal

func CreateClientInternal(name string, clientConfig *config.ClientConfig, config *config.Config) (Client, error)

type Download

type Download interface {
	Id() string // download task id in client
	Filename() string
	Size() int64
	SavePath() string
	Status() string // downloading|paused|completed|error|deleted|unknown
	Msg() string
}

type DownloadTask

type DownloadTask interface {
	GetUrl() string
	GetFilename() string // "foobar.rar"
	GetSavePath() string // "/root/Downloads"
	GetPaused() bool     // add task in paused state
}

type Downloads

type Downloads map[string]Download

id => Download

func (Downloads) Print

func (d Downloads) Print(output io.Writer, filter string)

type RegInfo

type RegInfo struct {
	Name    string
	Creator func(string, *config.ClientConfig, *config.Config) (Client, error)
}

type Status

type Status interface {
	DownloadSpeed() int64
}

Directories

Path Synopsis
aria2 client: https://aria2.github.io/manual/en/html/aria2c.html .
aria2 client: https://aria2.github.io/manual/en/html/aria2c.html .

Jump to

Keyboard shortcuts

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