Documentation ¶
Index ¶
- Constants
- type Client
- func (r *Client) Add(ctx context.Context, url string, extraArgs ...*FieldValue) error
- func (r *Client) AddStopped(ctx context.Context, url string, extraArgs ...*FieldValue) error
- func (r *Client) AddTorrent(ctx context.Context, data []byte, extraArgs ...*FieldValue) error
- func (r *Client) AddTorrentStopped(ctx context.Context, data []byte, extraArgs ...*FieldValue) error
- func (r *Client) CloseTorrent(ctx context.Context, t Torrent) error
- func (r *Client) Delete(ctx context.Context, t Torrent) error
- func (r *Client) DownRate(ctx context.Context) (int, error)
- func (r *Client) DownTotal(ctx context.Context) (int, error)
- func (r *Client) GetFiles(ctx context.Context, t Torrent) ([]File, error)
- func (r *Client) GetStatus(ctx context.Context, t Torrent) (Status, error)
- func (r *Client) GetTorrent(ctx context.Context, hash string) (Torrent, error)
- func (r *Client) GetTorrents(ctx context.Context, view View) ([]Torrent, error)
- func (r *Client) IP(ctx context.Context) (string, error)
- func (r *Client) IsActive(ctx context.Context, t Torrent) (bool, error)
- func (r *Client) IsOpen(ctx context.Context, t Torrent) (bool, error)
- func (r *Client) Name(ctx context.Context) (string, error)
- func (r *Client) OpenTorrent(ctx context.Context, t Torrent) error
- func (r *Client) PauseTorrent(ctx context.Context, t Torrent) error
- func (r *Client) ResumeTorrent(ctx context.Context, t Torrent) error
- func (r *Client) SetLabel(ctx context.Context, t Torrent, newLabel string) error
- func (r *Client) StartTorrent(ctx context.Context, t Torrent) error
- func (r *Client) State(ctx context.Context, t Torrent) (int, error)
- func (r *Client) StopTorrent(ctx context.Context, t Torrent) error
- func (r *Client) UpRate(ctx context.Context) (int, error)
- func (r *Client) UpTotal(ctx context.Context) (int, error)
- type Config
- type Field
- type FieldValue
- type File
- type Status
- type Torrent
- type View
Constants ¶
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 Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is used to communicate with a remote rTorrent instance
func (*Client) Add ¶
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 (*Client) AddStopped ¶
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 (*Client) AddTorrent ¶
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 (*Client) AddTorrentStopped ¶
func (r *Client) AddTorrentStopped(ctx context.Context, 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 (*Client) CloseTorrent ¶
CloseTorrent closes the torrent
func (*Client) DownRate ¶
DownRate returns the current download rate reported by this Client instance (bytes/s)
func (*Client) DownTotal ¶
DownTotal returns the total downloaded metric reported by this Client instance (bytes)
func (*Client) GetTorrent ¶
GetTorrent returns the torrent identified by the given hash
func (*Client) GetTorrents ¶
GetTorrents returns all the torrents reported by this Client instance
func (*Client) OpenTorrent ¶
OpenTorrent opens the torrent
func (*Client) PauseTorrent ¶
PauseTorrent pauses the torrent
func (*Client) ResumeTorrent ¶
ResumeTorrent resumes the torrent
func (*Client) StartTorrent ¶
StartTorrent starts the torrent
func (*Client) State ¶
State returns the state that the torrent is into It returns: 0 for stopped, 1 for started/paused
func (*Client) StopTorrent ¶
StopTorrent stops the torrent
type Field ¶
type Field string
Field represents an attribute on a Client entity that can be queried or set
func (Field) Cmd ¶
Cmd returns the representation of the field which allows it to be used a command with Client
func (Field) Query ¶
Query converts the field to a string which allows it to be queried Example:
DName.Query() // returns "d.name="
func (Field) SetValue ¶
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 ¶
FieldValue contains the Field and Value of an attribute on a rTorrent
func (*FieldValue) String ¶
func (f *FieldValue) String() string
type Status ¶
type Status struct { Completed bool CompletedBytes int DownRate int UpRate int Ratio float64 Size int }
Status represents the status of a torrent