rtorrent

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2022 License: MIT Imports: 5 Imported by: 10

Documentation

Index

Constants

View Source
const (
	// ViewMain represents the "main" view, containing all torrents
	ViewMain View = "main"
	// ViewStarted represents the "started" view, containing only torrents that have been started
	ViewStarted View = "started"
	// ViewStopped represents the "stopped" view, containing only torrents that have been stopped
	ViewStopped View = "stopped"
	// ViewHashing represents the "hashing" view, containing only torrents that are currently hashing
	ViewHashing View = "hashing"
	// ViewSeeding represents the "seeding" view, containing only torrents that are currently seeding
	ViewSeeding View = "seeding"

	// DName represents the name of a "Downloading Items"
	DName Field = "d.name"
	// DLabel represents the label of a "Downloading Item"
	DLabel Field = "d.custom1"
	// DSizeInBytes represents the size in bytes of a "Downloading Item"
	DSizeInBytes Field = "d.size_bytes"
	// DHash represents the hash of a "Downloading Item"
	DHash Field = "d.hash"
	// DBasePath represents the base path of a "Downloading Item"
	DBasePath Field = "d.base_path"
	// DDirectory represents the directory of a "Downloading Item"
	DDirectory Field = "d.directory"
	// DIsActive represents whether a "Downloading Item" is active or not
	DIsActive Field = "d.is_active"
	// DRatio represents the ratio of a "Downloading Item"
	DRatio Field = "d.ratio"
	// DComplete represents whether the "Downloading Item" is complete or not
	DComplete Field = "d.complete"
	// DCompletedBytes represents the total of completed bytes of the "Downloading Item"
	DCompletedBytes Field = "d.completed_bytes"
	// DDownRate represents the download rate of the "Downloading Item"
	DDownRate Field = "d.down.rate"
	// DUpRate represents the upload rate of the "Downloading Item"
	DUpRate Field = "d.up.rate"
	// DCreationTime represents the date the torrent was created
	DCreationTime Field = "d.creation_date"
	// DFinishedTime represents the date the torrent finished downloading
	DFinishedTime Field = "d.timestamp.finished"
	// DStartedTime represents the date the torrent started downloading
	DStartedTime Field = "d.timestamp.started"

	// FPath represents the path of a "File Item"
	FPath Field = "f.path"
	// FSizeInBytes represents the size in bytes of a "File Item"
	FSizeInBytes Field = "f.size_bytes"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Field added in v1.5.0

type Field string

Field represents a attribute on a RTorrent entity that can be queried or set

func (Field) Cmd added in v1.5.0

func (f Field) Cmd() string

Cmd returns the representation of the field which allows it to be used a command with RTorrent

func (Field) Query added in v1.5.0

func (f Field) Query() string

Query converts the field to a string which allows it to be queried Example:

DName.Query() // returns "d.name="

func (Field) SetValue added in v1.5.0

func (f Field) SetValue(value string) *FieldValue

SetValue returns a FieldValue struct which can be used to set the field on a particular item in rTorrent to the specified value

type FieldValue added in v1.5.0

type FieldValue struct {
	Field Field
	Value string
}

FieldValue contains the Field and Value of an attribute on a rTorrent

func (*FieldValue) String added in v1.5.0

func (f *FieldValue) String() string

type File

type File struct {
	Path string
	Size int
}

File represents a file in rTorrent

func (*File) Pretty

func (f *File) Pretty() string

Pretty returns a formatted string representing this File

type RTorrent

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

RTorrent is used to communicate with a remote rTorrent instance

func New

func New(addr string, insecure bool) *RTorrent

New returns a new instance of `RTorrent` Pass in a true value for `insecure` to turn off certificate verification

func (*RTorrent) Add added in v0.4.0

func (r *RTorrent) Add(url string, extraArgs ...*FieldValue) error

Add adds a new torrent by URL and starts the torrent

extraArgs can be any valid rTorrent rpc command. For instance:

Adds the Torrent by URL and sets the label on the torrent

Add("some-url", "d.custom1.set=\"my-label\"")

Or:

Add("some-url", DLabel.SetValue("my-label"))

Adds the Torrent by URL and sets the label as well as base path

Add("some-url", "d.custom1.set=\"my-label\"", "d.base_path=\"/some/valid/path\"")

Or:

Add("some-url", DLabel.SetValue("my-label"), DBasePath.SetValue("/some/valid/path"))

func (*RTorrent) AddStopped added in v1.4.0

func (r *RTorrent) AddStopped(url string, extraArgs ...*FieldValue) error

AddStopped adds a new torrent by URL in a stopped state

extraArgs can be any valid rTorrent rpc command. For instance:

Adds the Torrent by URL (stopped) and sets the label on the torrent

AddStopped("some-url", &FieldValue{"d.custom1", "my-label"})

Or:

AddStopped("some-url", DLabel.SetValue("my-label"))

Adds the Torrent by URL (stopped) and sets the label and base path

AddStopped("some-url", &FieldValue{"d.custom1", "my-label"}, &FiedValue{"d.base_path", "/some/valid/path"})

Or:

AddStopped("some-url", DLabel.SetValue("my-label"), DBasePath.SetValue("/some/valid/path"))

func (*RTorrent) AddTorrent added in v0.4.0

func (r *RTorrent) AddTorrent(data []byte, extraArgs ...*FieldValue) error

AddTorrent adds a new torrent by the torrent files data and starts the torrent

extraArgs can be any valid rTorrent rpc command. For instance:

Adds the Torrent file and sets the label on the torrent

Add(fileData, "d.custom1.set=\"my-label\"")

Or:

AddTorrent(fileData, DLabel.SetValue("my-label"))

Adds the Torrent file and sets the label and base path

Add(fileData, "d.custom1.set=\"my-label\"", "d.base_path=\"/some/valid/path\"")

Or:

AddTorrent(fileData, DLabel.SetValue("my-label"), DBasePath.SetValue("/some/valid/path"))

func (*RTorrent) AddTorrentStopped added in v1.4.0

func (r *RTorrent) AddTorrentStopped(data []byte, extraArgs ...*FieldValue) error

AddTorrentStopped adds a new torrent by the torrent files data but does not start the torrent

extraArgs can be any valid rTorrent rpc command. For instance:

Adds the Torrent file (stopped) and sets the label on the torrent

AddTorrentStopped(fileData, "d.custom1.set=\"my-label\"")

Or:

AddTorrentStopped(fileData, DLabel.SetValue("my-label"))

Adds the Torrent file and (stopped) sets the label and base path

AddTorrentStopped(fileData, "d.custom1.set=\"my-label\"", "d.base_path=\"/some/valid/path\"")

Or:

AddTorrentStopped(fileData, DLabel.SetValue("my-label"), DBasePath.SetValue("/some/valid/path"))

func (*RTorrent) CloseTorrent added in v1.8.0

func (r *RTorrent) CloseTorrent(t Torrent) error

CloseTorrent closes the torrent

func (*RTorrent) Delete added in v0.6.0

func (r *RTorrent) Delete(t Torrent) error

Delete removes the torrent

func (*RTorrent) DownRate added in v1.1.0

func (r *RTorrent) DownRate() (int, error)

DownRate returns the current download rate reported by this RTorrent instance (bytes/s)

func (*RTorrent) DownTotal

func (r *RTorrent) DownTotal() (int, error)

DownTotal returns the total downloaded metric reported by this RTorrent instance (bytes)

func (*RTorrent) GetFiles

func (r *RTorrent) GetFiles(t Torrent) ([]File, error)

GetFiles returns all of the files for a given `Torrent`

func (*RTorrent) GetStatus added in v1.1.0

func (r *RTorrent) GetStatus(t Torrent) (Status, error)

GetStatus returns the Status for a given Torrent

func (*RTorrent) GetTorrent added in v1.3.0

func (r *RTorrent) GetTorrent(hash string) (Torrent, error)

GetTorrent returns the torrent identified by the given hash

func (*RTorrent) GetTorrents

func (r *RTorrent) GetTorrents(view View) ([]Torrent, error)

GetTorrents returns all of the torrents reported by this RTorrent instance

func (*RTorrent) IP

func (r *RTorrent) IP() (string, error)

IP returns the IP reported by this RTorrent instance

func (*RTorrent) IsActive added in v1.8.0

func (r *RTorrent) IsActive(t Torrent) (bool, error)

IsActive checks if the torrent is active

func (*RTorrent) IsOpen added in v1.8.0

func (r *RTorrent) IsOpen(t Torrent) (bool, error)

IsOpen checks if the torrent is open

func (*RTorrent) Name

func (r *RTorrent) Name() (string, error)

Name returns the name reported by this RTorrent instance

func (*RTorrent) OpenTorrent added in v1.8.0

func (r *RTorrent) OpenTorrent(t Torrent) error

OpenTorrent opens the torrent

func (*RTorrent) PauseTorrent added in v1.8.0

func (r *RTorrent) PauseTorrent(t Torrent) error

PauseTorrent pauses the torrent

func (*RTorrent) ResumeTorrent added in v1.8.0

func (r *RTorrent) ResumeTorrent(t Torrent) error

ResumeTorrent resumes the torrent

func (*RTorrent) SetLabel

func (r *RTorrent) SetLabel(t Torrent, newLabel string) error

SetLabel sets the label on the given Torrent

func (*RTorrent) StartTorrent added in v1.8.0

func (r *RTorrent) StartTorrent(t Torrent) error

StartTorrent starts the torrent

func (*RTorrent) State added in v1.8.0

func (r *RTorrent) State(t Torrent) (int, error)

State returns the state that the torrent is into It returns: 0 for stopped, 1 for started/paused

func (*RTorrent) StopTorrent added in v1.8.0

func (r *RTorrent) StopTorrent(t Torrent) error

StopTorrent stops the torrent

func (*RTorrent) UpRate added in v1.1.0

func (r *RTorrent) UpRate() (int, error)

UpRate returns the current upload rate reported by this RTorrent instance (bytes/s)

func (*RTorrent) UpTotal

func (r *RTorrent) UpTotal() (int, error)

UpTotal returns the total uploaded metric reported by this RTorrent instance (bytes)

func (*RTorrent) WithHTTPClient added in v0.5.0

func (r *RTorrent) WithHTTPClient(client *http.Client) *RTorrent

WithHTTPClient allows you to a provide a custom http.Client.

type Status added in v1.1.0

type Status struct {
	Completed      bool
	CompletedBytes int
	DownRate       int
	UpRate         int
	Ratio          float64
	Size           int
}

Status represents the status of a torrent

type Torrent

type Torrent struct {
	Hash      string
	Name      string
	Path      string
	Size      int
	Label     string
	Completed bool
	Ratio     float64
	Created   time.Time
	Started   time.Time
	Finished  time.Time
}

Torrent represents a torrent in rTorrent

func (*Torrent) Pretty

func (t *Torrent) Pretty() string

Pretty returns a formatted string representing this Torrent

type View

type View string

View represents a "view" within RTorrent

Jump to

Keyboard shortcuts

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