Documentation ¶
Index ¶
- type Aria2
- func (a *Aria2) AddTorrent(filepath string, options Options) (gid string, err error)
- func (a *Aria2) AddUri(uri string, options Options) (gid string, err error)
- func (a *Aria2) ChangeGlobalOptions(options Options) error
- func (a *Aria2) ChangeOptions(gid string, options Options) error
- func (a *Aria2) GetDownloadInfo(gid string) DownloadInfo
- func (a *Aria2) GetGlobalOptions() Options
- func (a *Aria2) GetOptions(gid string) Options
- func (a *Aria2) Pause(gid string) bool
- func (a *Aria2) Remove(gid string) bool
- func (a *Aria2) Resume(gid string) bool
- func (a *Aria2) Run()
- func (a *Aria2) SetNotifier(notifier Notifier)
- func (a *Aria2) Shutdown() int
- type Config
- type DefaultNotifier
- type DownloadInfo
- type File
- type MetaInfo
- type Notifier
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Aria2 ¶
type Aria2 struct {
// contains filtered or unexported fields
}
Type definition for lib aria2, it holds a notifier.
func (*Aria2) AddTorrent ¶
AddTorrent adds a MetaInfo download with given torrent file path. This will return gid and files in torrent file if add successfully. User can choose specified files to download, change directory and so on.
func (*Aria2) AddUri ¶
AddUri adds a new download. The uris is an array of HTTP/FTP/SFTP/BitTorrent URIs (strings) pointing to the same resource. When adding BitTorrent Magnet URIs, uris must have only one element and it should be BitTorrent Magnet URI.
func (*Aria2) ChangeGlobalOptions ¶
ChangeGlobalOptions changes global options. See available options in https://aria2.github.io/manual/en/html/aria2c.html#input-file except for `checksum`, `index-out`, `out`, `pause` and `select-file`.
func (*Aria2) ChangeOptions ¶
ChangeOptions can change the options for aria2. See available options in https://aria2.github.io/manual/en/html/aria2c.html#input-file.
func (*Aria2) GetDownloadInfo ¶
func (a *Aria2) GetDownloadInfo(gid string) DownloadInfo
GetDownloadInfo gets current download information for given gid.
func (*Aria2) GetGlobalOptions ¶
GetGlobalOptions gets all global options of aria2.
func (*Aria2) GetOptions ¶
GetOptions gets all options for given gid.
func (*Aria2) Pause ¶
Pause pauses an active download for given gid. The status of the download will become `DOWNLOAD_PAUSED`. Use `Resume` to restart download.
func (*Aria2) Remove ¶
Remove removes download no matter what status it was. This will stop downloading and stop seeding(for torrent).
func (*Aria2) Run ¶
func (a *Aria2) Run()
Run starts event pooling. Note this will block current thread.
func (*Aria2) SetNotifier ¶
SetNotifier sets notifier to receive download notification from aria2.
type DefaultNotifier ¶
type DefaultNotifier struct{}
Type definition for default notifier which dose nothing.
func (DefaultNotifier) OnComplete ¶
func (n DefaultNotifier) OnComplete(gid string)
OnComplete implements Notifier interface.
func (DefaultNotifier) OnError ¶
func (n DefaultNotifier) OnError(gid string)
OnError implements Notifier interface.
func (DefaultNotifier) OnPause ¶
func (n DefaultNotifier) OnPause(gid string)
OnPause implements Notifier interface.
func (DefaultNotifier) OnStart ¶
func (n DefaultNotifier) OnStart(gid string)
OnStart implements Notifier interface.
func (DefaultNotifier) OnStop ¶
func (n DefaultNotifier) OnStop(gid string)
OnPause implements Notifier interface.
type DownloadInfo ¶
type DownloadInfo struct { Status int TotalLength int64 BytesCompleted int64 BytesUpload int64 DownloadSpeed int UploadSpeed int NumPieces int Connections int BitField string InfoHash string MetaInfo MetaInfo Files []File ErrorCode int FollowedByGid string }
Type definition for download information.
type MetaInfo ¶
type MetaInfo struct { Name string AnnounceList []string Comment string CreationUnix int64 Mode string }
Type definition for BitTorrent meta information.
type Notifier ¶
type Notifier interface { // OnStart will be invoked when aria2 started to download OnStart(gid string) // OnPause will be invoked when aria2 paused one download OnPause(gid string) // OnPause will be invoked when aria2 stopped one download OnStop(gid string) // OnComplete will be invoked when download completed OnComplete(gid string) // OnError will be invoked when an error occoured OnError(gid string) }
Type definition for notifier which can be used in aria2c json rpc notification.