builtin

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitDownloader

func InitDownloader()

func MonitorBuiltin

func MonitorBuiltin(recv, send chan MonitoredTorrent, ctx context.Context, monitor *TorrentProgressMonitor)

MonitorBuiltin monitors torrents and handles their state transitions. It listens for incoming MonitoredTorrent objects on the recv channel, processes them, and sends updated MonitoredTorrent objects on the send channel. The function also listens for context cancellation to gracefully exit.

Parameters: - recv: a channel from which MonitoredTorrent objects are received. - send: a channel to which updated MonitoredTorrent objects are sent. - ctx: a context to handle cancellation and timeout.

The function uses reflection to dynamically select from multiple channels and manage the state of each torrent. It tracks torrent states in a map and updates their status based on events such as receiving torrent info or completing the download.

Types

type Downloader

type Downloader struct {
	TorrentSeeker
	// contains filtered or unexported fields
}
var DefaultDownLoader *Downloader

func NewDownloader

func NewDownloader(c *DownloaderConfig) *Downloader

func (*Downloader) Download

func (d *Downloader) Download(s string, fOp FileOption, seeker TorrentSeeker) (t *torrent.Torrent, err error)

type DownloaderConfig

type DownloaderConfig struct {
	BaseDir    string
	Seeker     TorrentSeeker
	NopUpload  bool
	FakePeerID bool
}

type FileName

type FileName interface {
	Name() storage.FilePathMaker
}

type FileOption

type FileOption interface {
	FileName
	Dir() storage.TorrentDirFilePathMaker
}

type HttpUrlSeeker

type HttpUrlSeeker struct {
	*http.Client
}

func NewHttpSeeker

func NewHttpSeeker() *HttpUrlSeeker

func (*HttpUrlSeeker) Seek

func (hr *HttpUrlSeeker) Seek(n string) (*torrent.TorrentSpec, error)

type MonitoredTorrent

type MonitoredTorrent struct {
	TorrentInfo
	Size int64
	Url  string
}

type TorrentInfo

type TorrentInfo struct {
	Torrent *torrent.Torrent
	Rename  string
}

type TorrentProgress

type TorrentProgress struct {
	Percentage int    `json:"percentage"`
	Name       string `json:"name"`
}

type TorrentProgressList

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

func (*TorrentProgressList) Fin

func (l *TorrentProgressList) Fin() bool

func (*TorrentProgressList) Get

func (*TorrentProgressList) Put

func (l *TorrentProgressList) Put(dirty []TorrentProgress)

type TorrentProgressListSend

type TorrentProgressListSend struct {
	List []TorrentProgress `json:"list"`
	Fin  bool              `json:"fin"`
}

type TorrentProgressMonitor

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

func NewTorrentProgressMonitor

func NewTorrentProgressMonitor(ttl time.Duration) *TorrentProgressMonitor

func (*TorrentProgressMonitor) AddTorrent

func (tm *TorrentProgressMonitor) AddTorrent(t TorrentInfo)

func (*TorrentProgressMonitor) GetProgressList

func (tm *TorrentProgressMonitor) GetProgressList() []TorrentProgress

type TorrentSeeker

type TorrentSeeker interface {
	Seek(n string) (*torrent.TorrentSpec, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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