downloads

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const MIN_LEN_TO_SPLIT = 100 * 1e+6 // 100 mb

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func New

func New(opt Options, callback func(d Download)) (*Client, error)

func (*Client) Cancel

func (c *Client) Cancel(id int)

func (*Client) ClearCompleted

func (c *Client) ClearCompleted()

func (*Client) Get

func (c *Client) Get(id int) (Download, error)

func (*Client) GetAll

func (c *Client) GetAll() []Download

func (*Client) Pause

func (c *Client) Pause(id int)

func (*Client) Queue

func (c *Client) Queue(url, path string) (id int)

func (*Client) Resume

func (c *Client) Resume(id int)

func (*Client) Retry

func (c *Client) Retry(id int)

func (*Client) Run

func (c *Client) Run()

func (*Client) Shutdown

func (c *Client) Shutdown()

func (*Client) WithStatus

func (c *Client) WithStatus(s ...DownloadStatus) []Download

type Download

type Download struct {
	ID         int            `json:"id"`
	Name       string         `json:"name"`
	Status     DownloadStatus `json:"status"`
	Downloaded int            `json:"dl"`
	Total      int            `json:"total"`
	// contains filtered or unexported fields
}

func (Download) Path

func (d Download) Path() string

type DownloadStatus

type DownloadStatus int
const (
	Error DownloadStatus = iota
	Queued
	Paused
	Prefilling
	Downloading
	Finished
	Cancelled
)
type Header struct {
	ContentType   string
	ContentLength int
	FileName      string
}
func Head(url string) (header Header, err error)

type Options

type Options struct {
	Path          string
	MaxConcurrent int
	Splits        int
}

type SectionWriter

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

func NewSectionWriter

func NewSectionWriter(w io.WriterAt, off int64, n int64) *SectionWriter

NewSectionWriter returns a SectionWriter that writes to w starting at offset off and stops with EOF after n bytes.

func (*SectionWriter) Write

func (s *SectionWriter) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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