aria2

package
v0.48.4 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidURL      = errors.New("aria2: invalid URL")
	ErrRPCFailed       = errors.New("aria2: RPC call failed")
	ErrInvalidResponse = errors.New("aria2: invalid response")
)

Functions

This section is empty.

Types

type Client

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

Client represents an aria2 JSON-RPC client

func NewClient

func NewClient(url, secret string) (*Client, error)

NewClient creates a new aria2 client url: aria2 RPC URL (e.g., "http://localhost:6800/jsonrpc") secret: aria2 RPC secret token (optional, use empty string if not set)

func NewClientWithHTTPClient

func NewClientWithHTTPClient(url, secret string, httpClient *http.Client) (*Client, error)

NewClientWithHTTPClient creates a new aria2 client with custom HTTP client

func (c *Client) AddMetalink(ctx context.Context, metalink []byte, options Options) ([]string, error)

AddMetalink adds a new download with metalink file content

func (*Client) AddTorrent

func (c *Client) AddTorrent(ctx context.Context, torrent []byte, uris []string, options Options) (string, error)

AddTorrent adds a new download with torrent file content

func (*Client) AddURI

func (c *Client) AddURI(ctx context.Context, uris []string, options Options) (string, error)

AddURI adds a new download with URIs

func (*Client) ChangeGlobalOption

func (c *Client) ChangeGlobalOption(ctx context.Context, options Options) (string, error)

ChangeGlobalOption changes global options dynamically

func (*Client) ChangeOption

func (c *Client) ChangeOption(ctx context.Context, gid string, options Options) (string, error)

ChangeOption changes options of the download denoted by gid dynamically

func (*Client) ChangePosition

func (c *Client) ChangePosition(ctx context.Context, gid string, pos int, how string) (int, error)

ChangePosition changes the position of the download denoted by gid

func (*Client) ChangeURI

func (c *Client) ChangeURI(ctx context.Context, gid string, fileIndex int, delURIs []string, addURIs []string) ([]int, error)

ChangeURI changes the URI of the download denoted by gid

func (*Client) ForcePause

func (c *Client) ForcePause(ctx context.Context, gid string) (string, error)

ForcePause pauses the download denoted by gid forcefully

func (*Client) ForcePauseAll

func (c *Client) ForcePauseAll(ctx context.Context) (string, error)

ForcePauseAll pauses all downloads forcefully

func (*Client) ForceRemove

func (c *Client) ForceRemove(ctx context.Context, gid string) (string, error)

ForceRemove removes the download denoted by gid forcefully

func (*Client) ForceShutdown

func (c *Client) ForceShutdown(ctx context.Context) (string, error)

ForceShutdown shuts down aria2 forcefully

func (*Client) GetFiles

func (c *Client) GetFiles(ctx context.Context, gid string) ([]File, error)

GetFiles returns the file list of the download denoted by gid

func (*Client) GetGlobalOption

func (c *Client) GetGlobalOption(ctx context.Context) (Options, error)

GetGlobalOption returns the global options

func (*Client) GetGlobalStat

func (c *Client) GetGlobalStat(ctx context.Context) (*GlobalStat, error)

GetGlobalStat returns global statistics such as the overall download and upload speed

func (*Client) GetOption

func (c *Client) GetOption(ctx context.Context, gid string) (Options, error)

GetOption returns options of the download denoted by gid

func (*Client) GetPeers

func (c *Client) GetPeers(ctx context.Context, gid string) ([]any, error)

GetPeers returns a list of peers of the download denoted by gid

func (*Client) GetServers

func (c *Client) GetServers(ctx context.Context, gid string) ([]any, error)

GetServers returns currently connected HTTP(S)/FTP/SFTP servers of the download denoted by gid

func (*Client) GetSessionInfo

func (c *Client) GetSessionInfo(ctx context.Context) (map[string]any, error)

GetSessionInfo returns session information

func (*Client) GetURIs

func (c *Client) GetURIs(ctx context.Context, gid string) ([]URI, error)

GetURIs returns the URIs used in the download denoted by gid

func (*Client) GetVersion

func (c *Client) GetVersion(ctx context.Context) (*Version, error)

GetVersion returns the version of aria2 and the list of enabled features

func (*Client) ListMethods

func (c *Client) ListMethods(ctx context.Context) ([]string, error)

ListMethods lists all available RPC methods

func (*Client) ListNotifications

func (c *Client) ListNotifications(ctx context.Context) ([]string, error)

ListNotifications lists all available RPC notifications

func (*Client) MultiCall

func (c *Client) MultiCall(ctx context.Context, calls []map[string]any) ([]any, error)

MultiCall executes multiple method calls in a single request (system.multicall)

func (*Client) Pause

func (c *Client) Pause(ctx context.Context, gid string) (string, error)

Pause pauses the download denoted by gid

func (*Client) PauseAll

func (c *Client) PauseAll(ctx context.Context) (string, error)

PauseAll pauses all downloads

func (*Client) PurgeDownloadResult

func (c *Client) PurgeDownloadResult(ctx context.Context) (string, error)

PurgeDownloadResult purges completed/error/removed downloads

func (*Client) Remove

func (c *Client) Remove(ctx context.Context, gid string) (string, error)

Remove removes the download denoted by gid

func (*Client) RemoveDownloadResult

func (c *Client) RemoveDownloadResult(ctx context.Context, gid string) (string, error)

RemoveDownloadResult removes a completed/error/removed download denoted by gid

func (*Client) SaveSession

func (c *Client) SaveSession(ctx context.Context) (string, error)

SaveSession saves the current session to a file

func (*Client) Shutdown

func (c *Client) Shutdown(ctx context.Context) (string, error)

Shutdown shuts down aria2

func (*Client) TellActive

func (c *Client) TellActive(ctx context.Context, keys ...string) ([]Status, error)

TellActive returns a list of active downloads

func (*Client) TellStatus

func (c *Client) TellStatus(ctx context.Context, gid string, keys ...string) (*Status, error)

TellStatus returns the progress of the download denoted by gid

func (*Client) TellStopped

func (c *Client) TellStopped(ctx context.Context, offset, num int, keys ...string) ([]Status, error)

TellStopped returns a list of stopped downloads

func (*Client) TellWaiting

func (c *Client) TellWaiting(ctx context.Context, offset, num int, keys ...string) ([]Status, error)

TellWaiting returns a list of waiting downloads

func (*Client) Unpause

func (c *Client) Unpause(ctx context.Context, gid string) (string, error)

Unpause unpauses the download denoted by gid

func (*Client) UnpauseAll

func (c *Client) UnpauseAll(ctx context.Context) (string, error)

UnpauseAll unpauses all downloads

type File

type File struct {
	Index           string `json:"index"`
	Path            string `json:"path"`
	Length          string `json:"length"`
	CompletedLength string `json:"completedLength"`
	Selected        string `json:"selected"`
	URIs            []URI  `json:"uris"`
}

File represents a file in the download

type GlobalStat

type GlobalStat struct {
	DownloadSpeed   string `json:"downloadSpeed"`
	UploadSpeed     string `json:"uploadSpeed"`
	NumActive       string `json:"numActive"`
	NumWaiting      string `json:"numWaiting"`
	NumStopped      string `json:"numStopped"`
	NumStoppedTotal string `json:"numStoppedTotal"`
}

GlobalStat represents global statistics

type Options

type Options map[string]any

Options for download

type Status

type Status struct {
	GID             string   `json:"gid"`
	Status          string   `json:"status"`
	TotalLength     string   `json:"totalLength"`
	CompletedLength string   `json:"completedLength"`
	UploadLength    string   `json:"uploadLength"`
	Bitfield        string   `json:"bitfield,omitempty"`
	DownloadSpeed   string   `json:"downloadSpeed"`
	UploadSpeed     string   `json:"uploadSpeed"`
	InfoHash        string   `json:"infoHash,omitempty"`
	NumSeeders      string   `json:"numSeeders,omitempty"`
	Seeder          string   `json:"seeder,omitempty"`
	PieceLength     string   `json:"pieceLength,omitempty"`
	NumPieces       string   `json:"numPieces,omitempty"`
	Connections     string   `json:"connections"`
	ErrorCode       string   `json:"errorCode,omitempty"`
	ErrorMessage    string   `json:"errorMessage,omitempty"`
	FollowedBy      []string `json:"followedBy,omitempty"`
	Following       string   `json:"following,omitempty"`
	BelongsTo       string   `json:"belongsTo,omitempty"`
	Dir             string   `json:"dir"`
	Files           []File   `json:"files"`
	BitTorrent      struct {
		AnnounceList [][]string `json:"announceList,omitempty"`
		Comment      string     `json:"comment,omitempty"`
		CreationDate int64      `json:"creationDate,omitempty"`
		Mode         string     `json:"mode,omitempty"`
		Info         struct {
			Name string `json:"name,omitempty"`
		} `json:"info"`
	} `json:"bittorrent"`
	VerifiedLength         string `json:"verifiedLength,omitempty"`
	VerifyIntegrityPending string `json:"verifyIntegrityPending,omitempty"`
}

Status represents the status of a download

func (*Status) IsDownloadActive

func (s *Status) IsDownloadActive() bool

IsDownloadActive checks if the download is active

func (*Status) IsDownloadComplete

func (s *Status) IsDownloadComplete() bool

IsDownloadComplete checks if the download is complete

func (*Status) IsDownloadError

func (s *Status) IsDownloadError() bool

IsDownloadError checks if the download has an error

func (*Status) IsDownloadPaused

func (s *Status) IsDownloadPaused() bool

IsDownloadPaused checks if the download is paused

func (*Status) IsDownloadRemoved

func (s *Status) IsDownloadRemoved() bool

IsDownloadRemoved checks if the download is removed

func (*Status) IsDownloadWaiting

func (s *Status) IsDownloadWaiting() bool

IsDownloadWaiting checks if the download is waiting

type URI

type URI struct {
	URI    string `json:"uri"`
	Status string `json:"status"`
}

URI represents a URI for a file

type Version

type Version struct {
	Version         string   `json:"version"`
	EnabledFeatures []string `json:"enabledFeatures"`
}

Version represents aria2 version information

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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