Documentation
¶
Index ¶
- Variables
- func EnsureDir(dirName string) error
- func Ffprobe(filename string) (*ffprobeInfo, error)
- func Ffthumb(videofile, thumbfile, args string, jpg bool) error
- func GET(ctx context.Context, rawurl string) (*http.Response, error)
- type Config
- func (c *Config) GetDownloadDir() string
- func (c *Config) GetTorrentRatio() float64
- func (c *Config) GetTransferSlots() int
- func (c *Config) Lock(loc string)
- func (c *Config) RLock(loc string)
- func (c *Config) RUnlock(loc string)
- func (c *Config) SetDownloadDir(path string)
- func (c *Config) SetTorrentRatio(ratio float64)
- func (c *Config) SetTransferSlots(n int)
- func (c *Config) Unlock(loc string)
- type DownloadOptions
- type Downloader
- func (l *Downloader) Active() int
- func (l *Downloader) Add(rawurl string, opt *DownloadOptions) (Transfer, error)
- func (l *Downloader) Busy() bool
- func (l *Downloader) Downloading(name string) bool
- func (l *Downloader) Find(id string) (Transfer, error)
- func (l *Downloader) FindByURL(rawurl string) (Transfer, error)
- func (l *Downloader) ListActive() []Transfer
- func (l *Downloader) ListPending() []Transfer
- func (l *Downloader) Lock(loc string)
- func (l *Downloader) PostProcess(ctx context.Context, t *Transfer) error
- func (l *Downloader) RLock(loc string)
- func (l *Downloader) RUnlock(loc string)
- func (l *Downloader) Remove(id string) error
- func (l *Downloader) Unlock(loc string)
- func (l *Downloader) Uploading(name string) bool
- func (l *Downloader) Waiting() int
- type Transfer
- func (t Transfer) DownloadedBytes() int64
- func (t Transfer) Files() ([]os.FileInfo, error)
- func (t Transfer) IsActive() bool
- func (t Transfer) IsCompleted() bool
- func (t Transfer) IsStarted() bool
- func (t Transfer) MarkDownloading() error
- func (t Transfer) MarkUploading() error
- func (t Transfer) String() string
- func (t Transfer) TotalSeedSize() int64
- func (t Transfer) TotalSize() int64
- func (t Transfer) UnmarkDownloading() error
- func (t Transfer) UnmarkUploading() error
- func (t Transfer) UploadedBytes() int64
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrTransferNotFound = errors.New("download not found") ErrInsufficientStorage = errors.New("insufficient storage") )
Functions ¶
Types ¶
type Config ¶
type Config struct { UploadSpeed int64 DownloadSpeed int64 Logger *zap.SugaredLogger Space func() int64 TorrentAddr string TransferSlots int DownloadDir string TorrentRatio float64 // contains filtered or unexported fields }
func (*Config) SetDownloadDir ¶
func (*Config) SetTorrentRatio ¶
func (*Config) SetTransferSlots ¶
type DownloadOptions ¶
func NewDefaultOptions ¶
func NewDefaultOptions() *DownloadOptions
type Downloader ¶
type Downloader struct { Config *Config // contains filtered or unexported fields }
func NewDownloader ¶
func NewDownloader(cfg *Config) (*Downloader, error)
func (*Downloader) Active ¶
func (l *Downloader) Active() int
func (*Downloader) Add ¶
func (l *Downloader) Add(rawurl string, opt *DownloadOptions) (Transfer, error)
func (*Downloader) Busy ¶
func (l *Downloader) Busy() bool
func (*Downloader) Downloading ¶
func (l *Downloader) Downloading(name string) bool
func (*Downloader) ListActive ¶
func (l *Downloader) ListActive() []Transfer
func (*Downloader) ListPending ¶
func (l *Downloader) ListPending() []Transfer
func (*Downloader) Lock ¶
func (l *Downloader) Lock(loc string)
func (*Downloader) PostProcess ¶
func (l *Downloader) PostProcess(ctx context.Context, t *Transfer) error
func (*Downloader) RLock ¶
func (l *Downloader) RLock(loc string)
func (*Downloader) RUnlock ¶
func (l *Downloader) RUnlock(loc string)
func (*Downloader) Remove ¶
func (l *Downloader) Remove(id string) error
func (*Downloader) Unlock ¶
func (l *Downloader) Unlock(loc string)
func (*Downloader) Uploading ¶
func (l *Downloader) Uploading(name string) bool
func (*Downloader) Waiting ¶
func (l *Downloader) Waiting() int
type Transfer ¶
type Transfer struct { ID string URL *url.URL Created time.Time Started time.Time Completed time.Time Cancel *context.CancelFunc DownloadDir string Uploading bool SeedRatio float64 PostOptions *DownloadOptions Torrent *torrent.Torrent Error error // Friend downloads DownloadID string DownloadSize int64 }
func (Transfer) DownloadedBytes ¶
DownloadedBytes returns the downloaded bytes.
func (Transfer) IsCompleted ¶
IsCompleted returns true when the transfer has been completed.
func (Transfer) MarkDownloading ¶
MarkDownloading creates the .downloading file
func (Transfer) MarkUploading ¶
MarkUploading creates the .uploading file
func (Transfer) TotalSeedSize ¶
TotalSeedSize returns the length of the seeding target size in bytes.
func (Transfer) UnmarkDownloading ¶
UnmarkDownloading removes the .downloading file for the download
func (Transfer) UnmarkUploading ¶
UnmarkUploading removes the .uploading file for the upload
func (Transfer) UploadedBytes ¶
UploadedBytes returns uploaded bytes.
Click to show internal directories.
Click to hide internal directories.