downloader

package
v0.18.3 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const MaxPartSize = 1024 * 1024

MaxPartSize refer to https://core.telegram.org/api/files#downloading-files

Variables

This section is empty.

Functions

This section is empty.

Types

type Downloader

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

func New

func New(opts Options) *Downloader

func (*Downloader) Download

func (d *Downloader) Download(ctx context.Context, limit int) error

type Elem

type Elem interface {
	File() File
	To() io.WriterAt

	AsTakeout() bool
}

type File

type File interface {
	Location() tg.InputFileLocationClass
	Size() int64
	DC() int
}

type Iter

type Iter interface {
	Next(ctx context.Context) bool
	Value() Elem
	Err() error
}

type Options

type Options struct {
	Pool     dcpool.Pool
	Threads  int
	Iter     Iter
	Progress Progress
}

type Progress

type Progress interface {
	OnAdd(elem Elem)
	OnDownload(elem Elem, state ProgressState)
	OnDone(elem Elem, err error)
}

type ProgressState

type ProgressState struct {
	Downloaded int64
	Total      int64
}

Jump to

Keyboard shortcuts

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