transmissionrpc

package module
v0.0.0-...-8498607 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: MIT Imports: 17 Imported by: 9

README

TransmissionRPC

Go Reference Go report card

Golang bindings to Transmission (bittorrent) RPC interface.

Even if there is some high level wrappers/helpers, the goal of this lib is to stay close to the original API in terms of methods and payloads while enhancing certain types to be more "golangish": timestamps are converted from/to time.Time, numeric durations in time.Duration, booleans in numeric form are converted to real bool, etc...

Also payload generation aims to be precise: when several values can be added to a payload, only instanciated values will be forwarded (and kept !) to the final payload. This means that the default JSON marshalling (with omitempty) can't always be used and therefor a manual, reflect based, approach is used to build the final payload and accurately send what the user have instanciated, even if a value is at its default type value.

  • If you want a 100% compatible lib with rpc v15, please use the v1 releases.
  • If you want 100% compatible lib with rpc v16, please use the v2 releases.

Version v3 of this library is compatible with RPC version 17.

Getting started

Install the v3 with:

go get github.com/hekmon/transmissionrpc/v3

First the main client object must be instantiated with New(). In its basic form only host/ip, username and password must be provided. Default will apply for port (9091) rpc URI (/transmission/rpc) and others values.

transmissionbt := transmissionrpc.New("127.0.0.1", "rpcuser", "rpcpass", nil)

But advanced values can also be configured to your liking using AdvancedConfig. Each value of AdvancedConfig with a type default value will be replaced by the lib default value, so you can set only the ones you want:

transmissionbt := transmissionrpc.New("bt.mydomain.net", "rpcuser", "rpcpass",
    &transmissionrpc.AdvancedConfig{
        HTTPS: true,
        Port:  443,
    })

The remote RPC version can be checked against this library before starting to operate:

ok, serverVersion, serverMinimumVersion, err := transmission.RPCVersion()
if err != nil {
    panic(err)
}
if !ok {
    panic(fmt.Sprintf("Remote transmission RPC version (v%d) is incompatible with the transmission library (v%d): remote needs at least v%d",
        serverVersion, transmissionrpc.RPCVersion, serverMinimumVersion))
}
fmt.Printf("Remote transmission RPC version (v%d) is compatible with our transmissionrpc library (v%d)\n",
    serverVersion, transmissionrpc.RPCVersion)

Features

Torrent Requests
Torrent Action Requests

Each rpc methods here can work with ID list, hash list or recently-active magic word. Therefor, there is 3 golang method variants for each of them.

transmissionbt.TorrentXXXXIDs(...)
transmissionbt.TorrentXXXXHashes(...)
transmissionbt.TorrentXXXXRecentlyActive()
  • torrent-start

Check TorrentStartIDs(), TorrentStartHashes() and TorrentStartRecentlyActive().

Ex:

err := transmissionbt.TorrentStartIDs(context.TODO(), []int64{55})
if err != nil {
    fmt.Fprintln(os.Stderr, err)
} else {
    fmt.Println("yay")
}
  • torrent-start-now

Check TorrentStartNowIDs(), TorrentStartNowHashes() and TorrentStartNowRecentlyActive().

Ex:

err := transmissionbt.TorrentStartNowHashes(context.TODO(), []string{"f07e0b0584745b7bcb35e98097488d34e68623d0"})
if err != nil {
    fmt.Fprintln(os.Stderr, err)
} else {
    fmt.Println("yay")
}
  • torrent-stop

Check TorrentStopIDs(), TorrentStopHashes() and TorrentStopRecentlyActive().

Ex:

err := transmissionbt.TorrentStopIDs(context.TODO(), []int64{55})
if err != nil {
    fmt.Fprintln(os.Stderr, err)
} else {
    fmt.Println("yay")
}
  • torrent-verify

Check TorrentVerifyIDs(), TorrentVerifyHashes() and TorrentVerifyRecentlyActive().

Ex:

err := transmissionbt.TorrentVerifyHashes(context.TODO(), []string{"f07e0b0584745b7bcb35e98097488d34e68623d0"})
if err != nil {
    fmt.Fprintln(os.Stderr, err)
} else {
    fmt.Println("yay")
}
  • torrent-reannounce

Check TorrentReannounceIDs(), TorrentReannounceHashes() and TorrentReannounceRecentlyActive().

Ex:

err := transmissionbt.TorrentReannounceRecentlyActive(context.TODO())
if err != nil {
    fmt.Fprintln(os.Stderr, err)
} else {
    fmt.Println("yay")
}
Torrent Mutators
  • torrent-set

Mapped as TorrentSet().

Ex: apply a 1 MB/s limit to a torrent.

uploadLimited := true
uploadLimitKBps := int64(1000)
err := transmissionbt.TorrentSet(context.TODO(), transmissionrpc.TorrentSetPayload{
    IDs:           []int64{55},
    UploadLimited: &uploadLimited,
    UploadLimit:   &uploadLimitKBps,
})
if err != nil {
    fmt.Fprintln(os.Stderr, err)
} else {
    fmt.Println("yay")
}

There is a lot more mutators available.

Torrent Accessors
  • torrent-get

All fields for all torrents with TorrentGetAll():

torrents, err := transmissionbt.TorrentGetAll(context.TODO())
if err != nil {
    fmt.Fprintln(os.Stderr, err)
} else {
    fmt.Println(torrents) // meh it's full of pointers
}

All fields for a restricted list of ids with TorrentGetAllFor():

torrents, err := transmissionbt.TorrentGetAllFor(context.TODO(), []int64{31})
if err != nil {
    fmt.Fprintln(os.Stderr, err)
} else {
    fmt.Println(torrents) // meh it's still full of pointers
}

Some fields for some torrents with the low level accessor TorrentGet():

torrents, err := transmissionbt.TorrentGet(context.TODO(), []string{"status"}, []int64{54, 55})
if err != nil {
    fmt.Fprintln(os.Stderr, err)
} else {
    for _, torrent := range torrents {
        fmt.Println(torrent.Status) // the only instanciated field, as requested
    }
}

Some fields for all torrents, still with the low level accessor TorrentGet():

torrents, err := transmissionbt.TorrentGet(context.TODO(), []string{"id", "name", "hashString"}, nil)
if err != nil {
    fmt.Fprintln(os.Stderr, err)
} else {
    for _, torrent := range torrents {
        fmt.Println(torrent.ID)
        fmt.Println(torrent.Name)
        fmt.Println(torrent.HashString)
    }
}

Valid fields name can be found as JSON tag on the Torrent struct.

Adding a Torrent
  • torrent-add

Adding a torrent from a file (using TorrentAddFile wrapper):

filepath := "/home/hekmon/Downloads/ubuntu-17.10.1-desktop-amd64.iso.torrent"
torrent, err := transmissionbt.TorrentAddFile(context.TODO(), filepath)
if err != nil {
    fmt.Fprintln(os.Stderr, err)
} else {
    // Only 3 fields will be returned/set in the Torrent struct
    fmt.Println(*torrent.ID)
    fmt.Println(*torrent.Name)
    fmt.Println(*torrent.HashString)
}

Adding a torrent from a file (using TorrentAddFileDownloadDir wrapper) to a specified DownloadDir (this allows for separation of downloads to target folders):

filepath := "/home/hekmon/Downloads/ubuntu-17.10.1-desktop-amd64.iso.torrent"
torrent, err := transmissionbt.TorrentAddFileDownloadDir(context.TODO(), filepath, "/path/to/other/download/dir")
if err != nil {
    fmt.Fprintln(os.Stderr, err)
} else {
    // Only 3 fields will be returned/set in the Torrent struct
    fmt.Println(*torrent.ID)
    fmt.Println(*torrent.Name)
    fmt.Println(*torrent.HashString)
}

Adding a torrent from an URL (ex: a magnet) with the real TorrentAdd method:

magnet := "magnet:?xt=urn:btih:f07e0b0584745b7bcb35e98097488d34e68623d0&dn=ubuntu-17.10.1-desktop-amd64.iso&tr=http%3A%2F%2Ftorrent.ubuntu.com%3A6969%2Fannounce&tr=http%3A%2F%2Fipv6.torrent.ubuntu.com%3A6969%2Fannounce"
torrent, err := btserv.TorrentAdd(context.TODO(), transmissionrpc.TorrentAddPayload{
    Filename: &magnet,
})
if err != nil {
    fmt.Fprintln(os.Stderr, err)
} else {
    // Only 3 fields will be returned/set in the Torrent struct
    fmt.Println(*torrent.ID)
    fmt.Println(*torrent.Name)
    fmt.Println(*torrent.HashString)
}

Which would output:

55
ubuntu-17.10.1-desktop-amd64.iso
f07e0b0584745b7bcb35e98097488d34e68623d0

Adding a torrent from a file, starting it paused:

filepath := "/home/hekmon/Downloads/ubuntu-17.10.1-desktop-amd64.iso.torrent"
b64, err := transmissionrpc.File2Base64(filepath)
if err != nil {
    fmt.Fprintf(os.Stderr, "can't encode '%s' content as base64: %v", filepath, err)
} else {
    // Prepare and send payload
    paused := true
    torrent, err := transmissionbt.TorrentAdd(context.TODO(), transmissionrpc.TorrentAddPayload{MetaInfo: &b64, Paused: &paused})
}
Removing a Torrent
  • torrent-remove

Mapped as TorrentRemove().

Moving a Torrent
  • torrent-set-location

Mapped as TorrentSetLocation().

Renaming a Torrent path
  • torrent-rename-path

Mapped as TorrentRenamePath().

Session Requests
Session Arguments
  • session-set

Mapped as SessionArgumentsSet().

  • session-get

Mapped as SessionArgumentsGet().

Session Statistics
  • session-stats

Mapped as SessionStats().

Blocklist
  • blocklist-update

Mapped as BlocklistUpdate().

Port Checking
  • port-test

Mapped as PortTest().

Ex:

    st, err := transmissionbt.PortTest(context.TODO())
    if err != nil {
        fmt.Fprintln(os.Stderr, err)
    }
    if st {
        fmt.Println("Open!")
    }
Session Shutdown
  • session-close

Mapped as SessionClose().

Queue Movement Requests
  • queue-move-top

Mapped as QueueMoveTop().

  • queue-move-up

Mapped as QueueMoveUp().

  • queue-move-down

Mapped as QueueMoveDown().

  • queue-move-bottom

Mapped as QueueMoveBottom().

Free Space
  • free-space

Mappped as FreeSpace().

Ex: Get the space available for /data.

    freeSpace, err := transmissionbt.FreeSpace(context.TODO(), "/data")
    if err != nil {
        fmt.Fprintln(os.Stderr, err)
    } else  {
        fmt.Printd("%s | %d | %v", freeSpace, freeSpace, freeSpace)
    }
}

For more information about the freeSpace type, check the ComputerUnits library.

Bandwidth Groups
  • group-set

BandwidthGroupSet().

Ex: Set bandwidth group properties:

    honorSessionLimits      := true
    name                    := "bw_group1"
    speedLimitDownEnabled   := false
    speedLimitUpEnabled     := true
    speedLimitUp            := int64(20) // 20 KB/s
    
    payload := &transmissionrpc.BandwidthGroupSetPayload{
        HonorSessionLimits:     &honorSessionLimits,
        Name:                   &name,
        SpeedLimitDownEnabled:  &speedLimitDownEnabled,
        SpeedLimitUpEnabled:    &speedLimitUpEnabled,
        SpeedLimitUp:           &speedLimitUp,
    }
    
    if err = transmissionbt.BandwidthGroupSet(context.TODO(), *payload); err != nil {
        fmt.Fprintln(os.Stderr, err)
    } else {
        fmt.Printf("Successfully set bandwidth group %s\n", *payload.Name)
    }
  • group-get

BandwidthGroupGet(). BandwidthGroupGetAll()

Ex: Get the information for bandwidth groups bw_group1 and bw_group2.

    groupNames := []string{"bw_group1", "bw_group2"}
    fields := []string{
        "name",
        "speed-limit-down-enabled",
        "speed-limit-down",
        "speed-limit-up-enabled",
        "speed-limit-up"
    }
    
    bandwidthGroupsInfo, err := transmissionbt.BandwidthGroupGet(context.TODO(), fields, groupNames)
    if err != nil {
        fmt.Fprintln(os.Stderr, err)
    } else {
        fmt.Println(bandwidthGroupsInfo)
    }

Documentation

Index

Constants

View Source
const (
	// RPCVersion indicates the exact transmission RPC version this library is build against
	RPCVersion = 17
)

Variables

This section is empty.

Functions

func File2Base64

func File2Base64(filename string) (b64 string, err error)

File2Base64 returns the base64 encoding of the file provided by filename. This can then be passed as MetaInfo in TorrentAddPayload.

Types

type AdvancedConfig

type AdvancedConfig struct {
	HTTPS       bool
	Port        uint16
	RPCURI      string
	HTTPTimeout time.Duration
	UserAgent   string
	Debug       bool
}

AdvancedConfig handles options that are not mandatory for New(). Default value for HTTPS is false, default port is 9091, default RPC URI is '/transmission/rpc', default HTTPTimeout is 30s.

type BandwidthGroup

type BandwidthGroup struct {
	HonorSessionLimits    bool   `json:"honorSessionLimits"`
	Name                  string `json:"name"`
	SpeedLimitDownEnabled bool   `json:"speed-limit-down-enabled"`
	SpeedLimitDown        int64  `json:"speed-limit-down"`
	SpeedLimitUpEnabled   bool   `json:"speed-limit-up-enabled"`
	SpeedLimitUp          int64  `json:"speed-limit-up"`
}

BandwidthGroup represents all possible fields of data for a bandwidth group.

type BandwidthGroupSetPayload

type BandwidthGroupSetPayload struct {
	HonorSessionLimits    *bool   `json:"honorSessionLimits"`       // true if session upload limits are honored
	Name                  *string `json:"name"`                     // Bandwidth group name
	SpeedLimitDownEnabled *bool   `json:"speed-limit-down-enabled"` // true means enabled
	SpeedLimitDown        *int64  `json:"speed-limit-down"`         // max global download speed (KBps)
	SpeedLimitUpEnabled   *bool   `json:"speed-limit-up-enabled"`   // true means enabled
	SpeedLimitUp          *int64  `json:"speed-limit-up"`           // max global upload speed (KBps)
}

BandwidthGroupSetPayload contains all the mutators applicable on one bandwidth group.

type Client

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

Client is the base object to interract with a remote transmission rpc endpoint. It must be created with New().

func New

func New(host, user, password string, conf *AdvancedConfig) (c *Client, err error)

New returns an initialized and ready to use Controller

func (*Client) BandwidthGroupGet

func (c *Client) BandwidthGroupGet(ctx context.Context, fields []string, groups []string) (bandwidthGroups []BandwidthGroup, err error)

BandwidthGroupGet returns the given fields for each bandwidth group provided. If no bandwidth group name is provided, returns the given fields for all bandwidth groups.

func (*Client) BandwidthGroupGetAll

func (c *Client) BandwidthGroupGetAll(ctx context.Context) (bandwidthGroups []BandwidthGroup, err error)

BandwidthGroupGetAll returns all the known fields for all bandwidth groups.

func (*Client) BandwidthGroupSet

func (c *Client) BandwidthGroupSet(ctx context.Context, payload BandwidthGroupSetPayload) (err error)

BandwidthGroupSet applies a list of mutator(s) to a bandwidth group.

func (*Client) BlocklistUpdate

func (c *Client) BlocklistUpdate(ctx context.Context) (nbEntries int64, err error)

BlocklistUpdate triggers a blocklist update. It returns the number of entries of the updated blocklist.

func (*Client) FreeSpace

func (c *Client) FreeSpace(ctx context.Context, path string) (freeSpace cunits.Bits, err error)

FreeSpace allow to see how much free space is available in a client-specified folder.

func (*Client) PortTest

func (c *Client) PortTest(ctx context.Context) (open bool, err error)

PortTest allows tests to see if your incoming peer port is accessible from the outside world.

func (*Client) QueueMoveBottom

func (c *Client) QueueMoveBottom(ctx context.Context, IDs []int64) (err error)

QueueMoveBottom moves IDs to the bottom of the queue list.

func (*Client) QueueMoveDown

func (c *Client) QueueMoveDown(ctx context.Context, IDs []int64) (err error)

QueueMoveDown moves IDs of one position down on the queue list.

func (*Client) QueueMoveTop

func (c *Client) QueueMoveTop(ctx context.Context, IDs []int64) (err error)

QueueMoveTop moves IDs to the top of the queue list.

func (*Client) QueueMoveUp

func (c *Client) QueueMoveUp(ctx context.Context, IDs []int64) (err error)

QueueMoveUp moves IDs of one position up on the queue list.

func (*Client) RPCVersion

func (c *Client) RPCVersion(ctx context.Context) (ok bool, serverVersion int64, serverMinimumVersion int64, err error)

RPCVersion returns true if the lib RPC version is greater or equals to the remote server rpc minimum version.

func (*Client) SessionArgumentsGet

func (c *Client) SessionArgumentsGet(ctx context.Context, fields []string) (sessionArgs SessionArguments, err error)

SessionArgumentsGet returns global/session values for specified fields. See the JSON tags of the SessionArguments struct for valid fields. https://github.com/transmission/transmission/blob/4.0.2/docs/rpc-spec.md#412-accessors

func (*Client) SessionArgumentsGetAll

func (c *Client) SessionArgumentsGetAll(ctx context.Context) (sessionArgs SessionArguments, err error)

SessionArgumentsGetAll returns global/session values. https://github.com/transmission/transmission/blob/4.0.2/docs/rpc-spec.md#412-accessors

func (*Client) SessionArgumentsSet

func (c *Client) SessionArgumentsSet(ctx context.Context, payload SessionArguments) (err error)

SessionArgumentsSet allows to modify global/session values. https://github.com/transmission/transmission/blob/4.0.2/docs/rpc-spec.md#411-mutators

func (*Client) SessionClose

func (c *Client) SessionClose(ctx context.Context) (err error)

SessionClose tells the transmission session to shut down.

func (*Client) SessionStats

func (c *Client) SessionStats(ctx context.Context) (stats SessionStats, err error)

SessionStats returns all (current/cumulative) statistics.

func (*Client) TorrentAdd

func (c *Client) TorrentAdd(ctx context.Context, payload TorrentAddPayload) (torrent Torrent, err error)

TorrentAdd allows to send an Add payload. If successful (torrent added or duplicate) torrent return value will only have HashString, ID and Name fields set up.

func (*Client) TorrentAddFile

func (c *Client) TorrentAddFile(ctx context.Context, filepath string) (torrent Torrent, err error)

TorrentAddFile is wrapper to directly add a torrent file (it handles the base64 encoding and payload generation). If successful (torrent added or duplicate) torrent return value will only have HashString, ID and Name fields set up.

func (*Client) TorrentAddFileDownloadDir

func (c *Client) TorrentAddFileDownloadDir(ctx context.Context, filepath, downloaddir string) (torrent Torrent, err error)

TorrentAddFileDownloadDir is wrapper to directly add a torrent file (it handles the base64 encoding and payload generation) to a DownloadDir (not the default download dir). If successful (torrent added or duplicate) torrent return value will only have HashString, ID and Name fields set up.

func (*Client) TorrentGet

func (c *Client) TorrentGet(ctx context.Context, fields []string, ids []int64) (torrents []Torrent, err error)

TorrentGet returns the given of fields (mandatory) for each ids (optionnal).

func (*Client) TorrentGetAll

func (c *Client) TorrentGetAll(ctx context.Context) (torrents []Torrent, err error)

TorrentGetAll returns all the known fields for all the torrents.

func (*Client) TorrentGetAllFor

func (c *Client) TorrentGetAllFor(ctx context.Context, ids []int64) (torrents []Torrent, err error)

TorrentGetAllFor returns all known fields for the given torrent's ids.

func (*Client) TorrentGetAllForHashes

func (c *Client) TorrentGetAllForHashes(ctx context.Context, hashes []string) (torrents []Torrent, err error)

TorrentGetAllForHashes returns all known fields for the given torrent's ids by string (usually hash).

func (*Client) TorrentGetHashes

func (c *Client) TorrentGetHashes(ctx context.Context, fields []string, hashes []string) (torrents []Torrent, err error)

TorrentGetHashes returns the given of fields (mandatory) for each ids (optionnal).

func (*Client) TorrentReannounceHashes

func (c *Client) TorrentReannounceHashes(ctx context.Context, hashes []string) (err error)

TorrentReannounceHashes reannounces torrent(s) which hash is in the provided slice. Can be one, can be several, can be all (if slice is empty or nil).

func (*Client) TorrentReannounceIDs

func (c *Client) TorrentReannounceIDs(ctx context.Context, ids []int64) (err error)

TorrentReannounceIDs reannounces torrent(s) which id is in the provided slice. Can be one, can be several, can be all (if slice is empty or nil).

func (*Client) TorrentReannounceRecentlyActive

func (c *Client) TorrentReannounceRecentlyActive(ctx context.Context) (err error)

TorrentReannounceRecentlyActive reannounces torrent(s) which have been recently active.

func (*Client) TorrentRemove

func (c *Client) TorrentRemove(ctx context.Context, payload TorrentRemovePayload) (err error)

TorrentRemove allows to delete one or more torrents only or with their data.

func (*Client) TorrentRenamePath

func (c *Client) TorrentRenamePath(ctx context.Context, id int64, path, name string) (err error)

TorrentRenamePath allows to rename torrent name or path. 'path' is the path to the file or folder that will be renamed. 'name' the file or folder's new name

func (*Client) TorrentRenamePathHash

func (c *Client) TorrentRenamePathHash(ctx context.Context, hash, path, name string) (err error)

TorrentRenamePathHash allows to rename torrent name or path by its hash.

func (*Client) TorrentSet

func (c *Client) TorrentSet(ctx context.Context, payload TorrentSetPayload) (err error)

TorrentSet apply a list of mutator(s) to a list of torrent ids.

func (*Client) TorrentSetLocation

func (c *Client) TorrentSetLocation(ctx context.Context, id int64, location string, move bool) (err error)

TorrentSetLocation allows to set a new location for one or more torrents. 'location' is the new torrent location. 'move' if true, move from previous location. Otherwise, search "location" for file.

func (*Client) TorrentSetLocationHash

func (c *Client) TorrentSetLocationHash(ctx context.Context, hash, location string, move bool) (err error)

TorrentSetLocationHash allows to set a new location for one or more torrents. 'location' is the new torrent location. 'move' if true, move from previous location. Otherwise, search "location" for file.

func (*Client) TorrentStartHashes

func (c *Client) TorrentStartHashes(ctx context.Context, hashes []string) (err error)

TorrentStartHashes starts torrent(s) which hash is in the provided slice. Can be one, can be several, can be all (if slice is empty or nil).

func (*Client) TorrentStartIDs

func (c *Client) TorrentStartIDs(ctx context.Context, ids []int64) (err error)

TorrentStartIDs starts torrent(s) which id is in the provided slice. Can be one, can be several, can be all (if slice is empty or nil).

func (*Client) TorrentStartNowHashes

func (c *Client) TorrentStartNowHashes(ctx context.Context, hashes []string) (err error)

TorrentStartNowHashes starts (now) torrent(s) which hash is in the provided slice. Can be one, can be several, can be all (if slice is empty or nil).

func (*Client) TorrentStartNowIDs

func (c *Client) TorrentStartNowIDs(ctx context.Context, ids []int64) (err error)

TorrentStartNowIDs starts (now) torrent(s) which id is in the provided slice. Can be one, can be several, can be all (if slice is empty or nil).

func (*Client) TorrentStartNowRecentlyActive

func (c *Client) TorrentStartNowRecentlyActive(ctx context.Context) (err error)

TorrentStartNowRecentlyActive starts (now) torrent(s) which have been recently active.

func (*Client) TorrentStartRecentlyActive

func (c *Client) TorrentStartRecentlyActive(ctx context.Context) (err error)

TorrentStartRecentlyActive starts torrent(s) which have been recently active.

func (*Client) TorrentStopHashes

func (c *Client) TorrentStopHashes(ctx context.Context, hashes []string) (err error)

TorrentStopHashes stops torrent(s) which hash is in the provided slice. Can be one, can be several, can be all (if slice is empty or nil).

func (*Client) TorrentStopIDs

func (c *Client) TorrentStopIDs(ctx context.Context, ids []int64) (err error)

TorrentStopIDs stops torrent(s) which id is in the provided slice. Can be one, can be several, can be all (if slice is empty or nil).

func (*Client) TorrentStopRecentlyActive

func (c *Client) TorrentStopRecentlyActive(ctx context.Context) (err error)

TorrentStopRecentlyActive stops torrent(s) which have been recently active.

func (*Client) TorrentVerifyHashes

func (c *Client) TorrentVerifyHashes(ctx context.Context, hashes []string) (err error)

TorrentVerifyHashes verifys torrent(s) which hash is in the provided slice. Can be one, can be several, can be all (if slice is empty or nil).

func (*Client) TorrentVerifyIDs

func (c *Client) TorrentVerifyIDs(ctx context.Context, ids []int64) (err error)

TorrentVerifyIDs verifys torrent(s) which id is in the provided slice. Can be one, can be several, can be all (if slice is empty or nil).

func (*Client) TorrentVerifyRecentlyActive

func (c *Client) TorrentVerifyRecentlyActive(ctx context.Context) (err error)

TorrentVerifyRecentlyActive verifys torrent(s) which have been recently active.

type CumulativeStats

type CumulativeStats struct {
	DownloadedBytes int64 `json:"downloadedBytes"`
	FilesAdded      int64 `json:"filesAdded"`
	SecondsActive   int64 `json:"secondsActive"`
	SessionCount    int64 `json:"sessionCount"`
	UploadedBytes   int64 `json:"uploadedBytes"`
}

CumulativeStats is subset of SessionStats.

func (*CumulativeStats) GetDownloaded

func (cs *CumulativeStats) GetDownloaded() (downloaded cunits.Bits)

GetDownloaded returns cumulative stats downloaded size in a handy format

func (*CumulativeStats) GetUploaded

func (cs *CumulativeStats) GetUploaded() (uploaded cunits.Bits)

GetUploaded returns cumulative stats uploaded size in a handy format

type CurrentStats

type CurrentStats struct {
	DownloadedBytes int64 `json:"downloadedBytes"`
	FilesAdded      int64 `json:"filesAdded"`
	SecondsActive   int64 `json:"secondsActive"`
	SessionCount    int64 `json:"sessionCount"`
	UploadedBytes   int64 `json:"uploadedBytes"`
}

CurrentStats is subset of SessionStats.

func (*CurrentStats) GetDownloaded

func (cs *CurrentStats) GetDownloaded() (downloaded cunits.Bits)

GetDownloaded returns current stats downloaded size in a handy format

func (*CurrentStats) GetUploaded

func (cs *CurrentStats) GetUploaded() (uploaded cunits.Bits)

GetUploaded returns current stats uploaded size in a handy format

type HTTPStatusCode

type HTTPStatusCode int

HTTPStatusCode is a custom error type for HTTP errors

func (HTTPStatusCode) Error

func (hsc HTTPStatusCode) Error() string

type Peer

type Peer struct {
	Address              string  `json:"address"`
	ClientName           string  `json:"clientName"`
	ClientIsChoked       bool    `json:"clientIsChoked"`
	ClientIsint64erested bool    `json:"clientIsint64erested"`
	FlagStr              string  `json:"flagStr"`
	IsDownloadingFrom    bool    `json:"isDownloadingFrom"`
	IsEncrypted          bool    `json:"isEncrypted"`
	IsIncoming           bool    `json:"isIncoming"`
	IsUploadingTo        bool    `json:"isUploadingTo"`
	IsUTP                bool    `json:"isUTP"`
	PeerIsChoked         bool    `json:"peerIsChoked"`
	PeerIsint64erested   bool    `json:"peerIsint64erested"`
	Port                 int64   `json:"port"`
	Progress             float64 `json:"progress"`
	RateToClient         int64   `json:"rateToClient"` // B/s
	RateToPeer           int64   `json:"rateToPeer"`   // B/s
}

Peer represent a peer metadata of a torrent's peer list.

func (*Peer) ConvertDownloadSpeed

func (p *Peer) ConvertDownloadSpeed() (speed cunits.Bits)

ConvertDownloadSpeed will return the download speed from peer as cunits.Bits/second

func (*Peer) ConvertUploadSpeed

func (p *Peer) ConvertUploadSpeed() (speed cunits.Bits)

ConvertUploadSpeed will return the upload speed to peer as cunits.Bits/second

type SeedRatioMode

type SeedRatioMode int64

SeedRatioMode represents a torrent current seeding mode

const (
	// SeedRatioModeGlobal represents the use of the global ratio for a torrent
	SeedRatioModeGlobal SeedRatioMode = 0
	// SeedRatioModeCustom represents the use of a custom ratio for a torrent
	SeedRatioModeCustom SeedRatioMode = 1
	// SeedRatioModeNoRatio represents the absence of ratio for a torrent
	SeedRatioModeNoRatio SeedRatioMode = 2
)

func (SeedRatioMode) GoString

func (srm SeedRatioMode) GoString() string

GoString implements the GoStringer interface from the stdlib fmt package

func (SeedRatioMode) String

func (srm SeedRatioMode) String() string

type SessionArguments

type SessionArguments struct {
	AltSpeedDown                     *int64   `json:"alt-speed-down"`                       // max global download speed (KBps)
	AltSpeedEnabled                  *bool    `json:"alt-speed-enabled"`                    // true means use the alt speeds
	AltSpeedTimeBegin                *int64   `json:"alt-speed-time-begin"`                 // when to turn on alt speeds (units: minutes after midnight)
	AltSpeedTimeEnabled              *bool    `json:"alt-speed-time-enabled"`               // true means the scheduled on/off times are used
	AltSpeedTimeEnd                  *int64   `json:"alt-speed-time-end"`                   // when to turn off alt speeds (units: same)
	AltSpeedTimeDay                  *int64   `json:"alt-speed-time-day"`                   // what day(s) to turn on alt speeds (look at tr_sched_day)
	AltSpeedUp                       *int64   `json:"alt-speed-up"`                         // max global upload speed (KBps)
	BlocklistURL                     *string  `json:"blocklist-url"`                        // location of the blocklist to use for "blocklist-update"
	BlocklistEnabled                 *bool    `json:"blocklist-enabled"`                    // true means enabled
	BlocklistSize                    *int64   `json:"blocklist-size"`                       // number of rules in the blocklist
	CacheSizeMB                      *int64   `json:"cache-size-mb"`                        // maximum size of the disk cache (MB)
	ConfigDir                        *string  `json:"config-dir"`                           // location of transmission's configuration directory
	DefaultTrackers                  *string  `json:"default-trackers"`                     // list of default trackers to use on public torrents
	DownloadDir                      *string  `json:"download-dir"`                         // default path to download torrents
	DownloadQueueSize                *int64   `json:"download-queue-size"`                  // max number of torrents to download at once (see download-queue-enabled)
	DownloadQueueEnabled             *bool    `json:"download-queue-enabled"`               // if true, limit how many torrents can be downloaded at once
	DHTEnabled                       *bool    `json:"dht-enabled"`                          // true means allow dht in public torrents
	Encryption                       *string  `json:"encryption"`                           // "required", "preferred", "tolerated"
	IdleSeedingLimit                 *int64   `json:"idle-seeding-limit"`                   // torrents we're seeding will be stopped if they're idle for this long
	IdleSeedingLimitEnabled          *bool    `json:"idle-seeding-limit-enabled"`           // true if the seeding inactivity limit is honored by default
	IncompleteDir                    *string  `json:"incomplete-dir"`                       // path for incomplete torrents, when enabled
	IncompleteDirEnabled             *bool    `json:"incomplete-dir-enabled"`               // true means keep torrents in incomplete-dir until done
	LPDEnabled                       *bool    `json:"lpd-enabled"`                          // true means allow Local Peer Discovery in public torrents
	PeerLimitGlobal                  *int64   `json:"peer-limit-global"`                    // maximum global number of peers
	PeerLimitPerTorrent              *int64   `json:"peer-limit-per-torrent"`               // maximum global number of peers
	PEXEnabled                       *bool    `json:"pex-enabled"`                          // true means allow pex in public torrents
	PeerPort                         *int64   `json:"peer-port"`                            // port number
	PeerPortRandomOnStart            *bool    `json:"peer-port-random-on-start"`            // true means pick a random peer port on launch
	PortForwardingEnabled            *bool    `json:"port-forwarding-enabled"`              // true means enabled
	QueueStalledEnabled              *bool    `json:"queue-stalled-enabled"`                // whether or not to consider idle torrents as stalled
	QueueStalledMinutes              *int64   `json:"queue-stalled-minutes"`                // torrents that are idle for N minuets aren't counted toward seed-queue-size or download-queue-size
	RenamePartialFiles               *bool    `json:"rename-partial-files"`                 // true means append ".part" to incomplete files
	RPCVersion                       *int64   `json:"rpc-version"`                          // the current RPC API version
	RPCVersionMinimum                *int64   `json:"rpc-version-minimum"`                  // the minimum RPC API version supported
	RPCVersionSemVer                 *string  `json:"rpc-version-semver"`                   // the current RPC API version in a semver-compatible string
	ScriptTorrentAddedEnabled        *bool    `json:"script-torrent-added-enabled"`         // whether or not to call the added script
	ScriptTorrentAddedFilename       *string  `json:"script-torrent-added-filename"`        //filename of the script to run
	ScriptTorrentDoneFilename        *string  `json:"script-torrent-done-filename"`         // filename of the script to run
	ScriptTorrentDoneEnabled         *bool    `json:"script-torrent-done-enabled"`          // whether or not to call the "done" script
	ScriptTorrentDoneSeedingEnabled  *bool    `json:"script-torrent-done-seeding-enabled"`  // whether or not to call the seeding-done script
	ScriptTorrentDoneSeedingFilename *string  `json:"script-torrent-done-seeding-filename"` // filename of the script to run
	SeedRatioLimit                   *float64 `json:"seedRatioLimit"`                       // the default seed ratio for torrents to use
	SeedRatioLimited                 *bool    `json:"seedRatioLimited"`                     // true if seedRatioLimit is honored by default
	SeedQueueSize                    *int64   `json:"seed-queue-size"`                      // max number of torrents to uploaded at once (see seed-queue-enabled)
	SeedQueueEnabled                 *bool    `json:"seed-queue-enabled"`                   // if true, limit how many torrents can be uploaded at once
	SessionID                        *string  `json:"session-id"`                           // the current session ID
	SpeedLimitDown                   *int64   `json:"speed-limit-down"`                     // max global download speed (KBps)
	SpeedLimitDownEnabled            *bool    `json:"speed-limit-down-enabled"`             // true means enabled
	SpeedLimitUp                     *int64   `json:"speed-limit-up"`                       // max global upload speed (KBps)
	SpeedLimitUpEnabled              *bool    `json:"speed-limit-up-enabled"`               // true means enabled
	StartAddedTorrents               *bool    `json:"start-added-torrents"`                 // true means added torrents will be started right away
	TrashOriginalTorrentFiles        *bool    `json:"trash-original-torrent-files"`         // true means the .torrent file of added torrents will be deleted
	Units                            *Units   `json:"units"`                                // see units below
	UTPEnabled                       *bool    `json:"utp-enabled"`                          // true means allow utp
	Version                          *string  `json:"version"`                              // long version string "$version ($revision)"
}

SessionArguments represents all the global/session values.

func (SessionArguments) MarshalJSON

func (sa SessionArguments) MarshalJSON() (data []byte, err error)

MarshalJSON allows to marshall into JSON only the non nil fields. It differs from 'omitempty' which also skip default values (as 0 or false which can be valid here).

type SessionStats

type SessionStats struct {
	ActiveTorrentCount int64           `json:"activeTorrentCount"`
	CumulativeStats    CumulativeStats `json:"cumulative-stats"`
	CurrentStats       CurrentStats    `json:"current-stats"`
	DownloadSpeed      int64           `json:"downloadSpeed"`
	PausedTorrentCount int64           `json:"pausedTorrentCount"`
	TorrentCount       int64           `json:"torrentCount"`
	UploadSpeed        int64           `json:"uploadSpeed"`
}

SessionStats represents all (current/cumulative) statistics.

type Torrent

type Torrent struct {
	ActivityDate            *time.Time         `json:"activityDate"`
	AddedDate               *time.Time         `json:"addedDate"`
	Availability            []*int64           `json:"availability"` // RPC v17
	BandwidthPriority       *int64             `json:"bandwidthPriority"`
	Comment                 *string            `json:"comment"`
	CorruptEver             *int64             `json:"corruptEver"`
	Creator                 *string            `json:"creator"`
	DateCreated             *time.Time         `json:"dateCreated"`
	DesiredAvailable        *int64             `json:"desiredAvailable"`
	DoneDate                *time.Time         `json:"doneDate"`
	DownloadDir             *string            `json:"downloadDir"`
	DownloadedEver          *int64             `json:"downloadedEver"`
	DownloadLimit           *int64             `json:"downloadLimit"`
	DownloadLimited         *bool              `json:"downloadLimited"`
	EditDate                *time.Time         `json:"editDate"`
	Error                   *int64             `json:"error"`
	ErrorString             *string            `json:"errorString"`
	Eta                     *int64             `json:"eta"`
	EtaIdle                 *int64             `json:"etaIdle"`
	FileCount               *int64             `json:"file-count"` // RPC v17
	Files                   []*TorrentFile     `json:"files"`
	FileStats               []*TorrentFileStat `json:"fileStats"`
	Group                   *string            `json:"group"` // RPC v17
	HashString              *string            `json:"hashString"`
	HaveUnchecked           *int64             `json:"haveUnchecked"`
	HaveValid               *int64             `json:"haveValid"`
	HonorsSessionLimits     *bool              `json:"honorsSessionLimits"`
	ID                      *int64             `json:"id"`
	IsFinished              *bool              `json:"isFinished"`
	IsPrivate               *bool              `json:"isPrivate"`
	IsStalled               *bool              `json:"isStalled"`
	Labels                  []string           `json:"labels"` // RPC v16
	LeftUntilDone           *int64             `json:"leftUntilDone"`
	MagnetLink              *string            `json:"magnetLink"`
	ManualAnnounceTime      *int64             `json:"manualAnnounceTime"`
	MaxConnectedPeers       *int64             `json:"maxConnectedPeers"`
	MetadataPercentComplete *float64           `json:"metadataPercentComplete"`
	Name                    *string            `json:"name"`
	PeerLimit               *int64             `json:"peer-limit"`
	Peers                   []*Peer            `json:"peers"`
	PeersConnected          *int64             `json:"peersConnected"`
	PeersFrom               *TorrentPeersFrom  `json:"peersFrom"`
	PeersGettingFromUs      *int64             `json:"peersGettingFromUs"`
	PeersSendingToUs        *int64             `json:"peersSendingToUs"`
	PercentComplete         *float64           `json:"percentComplete"` // RPC v17
	PercentDone             *float64           `json:"percentDone"`
	Pieces                  *string            `json:"pieces"`
	PieceCount              *int64             `json:"pieceCount"`
	PieceSize               *cunits.Bits       `json:"pieceSize"`
	Priorities              []int64            `json:"priorities"`
	PrimaryMimeType         *string            `json:"primary-mime-type"` // RPC v17
	QueuePosition           *int64             `json:"queuePosition"`
	RateDownload            *int64             `json:"rateDownload"` // B/s
	RateUpload              *int64             `json:"rateUpload"`   // B/s
	RecheckProgress         *float64           `json:"recheckProgress"`
	SecondsDownloading      *int64             `json:"secondsDownloading"`
	SecondsSeeding          *time.Duration     `json:"secondsSeeding"`
	SeedIdleLimit           *int64             `json:"seedIdleLimit"`
	SeedIdleMode            *int64             `json:"seedIdleMode"`
	SeedRatioLimit          *float64           `json:"seedRatioLimit"`
	SeedRatioMode           *SeedRatioMode     `json:"seedRatioMode"`
	SizeWhenDone            *cunits.Bits       `json:"sizeWhenDone"`
	StartDate               *time.Time         `json:"startDate"`
	Status                  *TorrentStatus     `json:"status"`
	Trackers                []*Tracker         `json:"trackers"`
	TrackerList             *string            `json:"trackerList"`
	TrackerStats            []*TrackerStats    `json:"trackerStats"`
	TotalSize               *cunits.Bits       `json:"totalSize"`
	TorrentFile             *string            `json:"torrentFile"`
	UploadedEver            *int64             `json:"uploadedEver"`
	UploadLimit             *int64             `json:"uploadLimit"`
	UploadLimited           *bool              `json:"uploadLimited"`
	UploadRatio             *float64           `json:"uploadRatio"`
	Wanted                  []bool             `json:"wanted"`
	WebSeeds                []string           `json:"webseeds"`
	WebSeedsSendingToUs     *int64             `json:"webseedsSendingToUs"`
}

Torrent represents all the possible fields of data for a torrent. All fields are pointers to detect if the value is nil (field not requested) or default real default value.

func (*Torrent) ConvertDownloadSpeed

func (t *Torrent) ConvertDownloadSpeed() (speed cunits.Bits)

ConvertDownloadSpeed will return the download speed as cunits.Bitss/second

func (*Torrent) ConvertUploadSpeed

func (t *Torrent) ConvertUploadSpeed() (speed cunits.Bits)

ConvertUploadSpeed will return the upload speed as cunits.Bitss/second

func (Torrent) MarshalJSON

func (t Torrent) MarshalJSON() (data []byte, err error)

MarshalJSON allows to convert back golang values to original payload values.

func (*Torrent) UnmarshalJSON

func (t *Torrent) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON allows to convert timestamps to golang time.Time values.

type TorrentAddPayload

type TorrentAddPayload struct {
	Cookies           *string  `json:"cookies"`           // pointer to a string of one or more cookies
	DownloadDir       *string  `json:"download-dir"`      // path to download the torrent to
	Filename          *string  `json:"filename"`          // filename or URL of the .torrent file
	Labels            []string `json:"labels"`            // Labels for the torrent
	MetaInfo          *string  `json:"metainfo"`          // base64-encoded .torrent content
	Paused            *bool    `json:"paused"`            // if true, don't start the torrent
	PeerLimit         *int64   `json:"peer-limit"`        // maximum number of peers
	BandwidthPriority *int64   `json:"bandwidthPriority"` // torrent's bandwidth tr_priority_t
	FilesWanted       []int64  `json:"files-wanted"`      // indices of file(s) to download
	FilesUnwanted     []int64  `json:"files-unwanted"`    // indices of file(s) to not download
	PriorityHigh      []int64  `json:"priority-high"`     // indices of high-priority file(s)
	PriorityLow       []int64  `json:"priority-low"`      // indices of low-priority file(s)
	PriorityNormal    []int64  `json:"priority-normal"`   // indices of normal-priority file(s)
}

TorrentAddPayload represents the data to send in order to add a torrent.

func (TorrentAddPayload) MarshalJSON

func (tap TorrentAddPayload) MarshalJSON() (data []byte, err error)

MarshalJSON allows to marshall into JSON only the non nil fields. It differs from 'omitempty' which also skip default values (as 0 or false which can be valid here).

type TorrentFile

type TorrentFile struct {
	BytesCompleted int64  `json:"bytesCompleted"`
	Length         int64  `json:"length"`
	Name           string `json:"name"`
}

TorrentFile represent one file from a Torrent.

type TorrentFileStat

type TorrentFileStat struct {
	BytesCompleted int64 `json:"bytesCompleted"`
	Wanted         bool  `json:"wanted"`
	Priority       int64 `json:"priority"`
}

TorrentFileStat represents the metadata of a torrent's file.

type TorrentPeersFrom

type TorrentPeersFrom struct {
	FromCache    int64 `json:"fromCache"`
	FromDHT      int64 `json:"fromDht"`
	FromIncoming int64 `json:"fromIncoming"`
	FromLPD      int64 `json:"fromLpd"`
	FromLTEP     int64 `json:"fromLtep"`
	FromPEX      int64 `json:"fromPex"`
	FromTracker  int64 `json:"fromTracker"`
}

TorrentPeersFrom represents the peers statistics of a torrent.

type TorrentRemovePayload

type TorrentRemovePayload struct {
	IDs             []int64 `json:"ids"`
	DeleteLocalData bool    `json:"delete-local-data"`
}

TorrentRemovePayload holds the torrent id(s) to delete with a data deletion flag.

type TorrentSetPayload

type TorrentSetPayload struct {
	BandwidthPriority   *int64         `json:"bandwidthPriority"`   // this torrent's bandwidth tr_priority_t
	DownloadLimit       *int64         `json:"downloadLimit"`       // maximum download speed (KBps)
	DownloadLimited     *bool          `json:"downloadLimited"`     // true if "downloadLimit" is honored
	FilesWanted         []int64        `json:"files-wanted"`        // indices of file(s) to download
	FilesUnwanted       []int64        `json:"files-unwanted"`      // indices of file(s) to not download
	Group               *string        `json:"group"`               // bandwidth group to add torrent to
	HonorsSessionLimits *bool          `json:"honorsSessionLimits"` // true if session upload limits are honored
	IDs                 []int64        `json:"ids"`                 // torrent list
	Labels              []string       `json:"labels"`              // RPC v16: strings of user-defined labels
	Location            *string        `json:"location"`            // new location of the torrent's content
	PeerLimit           *int64         `json:"peer-limit"`          // maximum number of peers
	PriorityHigh        []int64        `json:"priority-high"`       // indices of high-priority file(s)
	PriorityLow         []int64        `json:"priority-low"`        // indices of low-priority file(s)
	PriorityNormal      []int64        `json:"priority-normal"`     // indices of normal-priority file(s)
	QueuePosition       *int64         `json:"queuePosition"`       // position of this torrent in its queue [0...n)
	SeedIdleLimit       *time.Duration `json:"seedIdleLimit"`       // torrent-level number of minutes of seeding inactivity
	SeedIdleMode        *int64         `json:"seedIdleMode"`        // which seeding inactivity to use
	SeedRatioLimit      *float64       `json:"seedRatioLimit"`      // torrent-level seeding ratio
	SeedRatioMode       *SeedRatioMode `json:"seedRatioMode"`       // which ratio mode to use
	TrackerList         *string        `json:"trackerList"`         // string of announce URLs, one per line, and a blank line between tiers
	UploadLimit         *int64         `json:"uploadLimit"`         // maximum upload speed (KBps)
	UploadLimited       *bool          `json:"uploadLimited"`       // true if "uploadLimit" is honored
}

TorrentSetPayload contains all the mutators appliable on one torrent.

func (TorrentSetPayload) MarshalJSON

func (tsp TorrentSetPayload) MarshalJSON() (data []byte, err error)

MarshalJSON allows to marshall into JSON only the non nil fields. It differs from 'omitempty' which also skip default values (as 0 or false which can be valid here).

type TorrentStatus

type TorrentStatus int64

TorrentStatus binds torrent status to a status code

const (
	// TorrentStatusStopped represents a stopped torrent
	TorrentStatusStopped TorrentStatus = 0
	// TorrentStatusCheckWait represents a torrent queued for files checking
	TorrentStatusCheckWait TorrentStatus = 1
	// TorrentStatusCheck represents a torrent which files are currently checked
	TorrentStatusCheck TorrentStatus = 2
	// TorrentStatusDownloadWait represents a torrent queue to download
	TorrentStatusDownloadWait TorrentStatus = 3
	// TorrentStatusDownload represents a torrent currently downloading
	TorrentStatusDownload TorrentStatus = 4
	// TorrentStatusSeedWait represents a torrent queued to seed
	TorrentStatusSeedWait TorrentStatus = 5
	// TorrentStatusSeed represents a torrent currently seeding
	TorrentStatusSeed TorrentStatus = 6
	// TorrentStatusIsolated represents a torrent which can't find peers
	TorrentStatusIsolated TorrentStatus = 7
)

func (TorrentStatus) GoString

func (status TorrentStatus) GoString() string

GoString implements the GoStringer interface from the stdlib fmt package

func (TorrentStatus) String

func (status TorrentStatus) String() string

type Tracker

type Tracker struct {
	Announce string `json:"announce"`
	ID       int64  `json:"id"`
	Scrape   string `json:"scrape"`
	SiteName string `json:"sitename"`
	Tier     int64  `json:"tier"`
}

Tracker represent the base data of a torrent's tracker.

type TrackerStats

type TrackerStats struct {
	Announce              string    `json:"announce"`
	AnnounceState         int64     `json:"announceState"`
	DownloadCount         int64     `json:"downloadCount"`
	HasAnnounced          bool      `json:"hasAnnounced"`
	HasScraped            bool      `json:"hasScraped"`
	Host                  string    `json:"host"`
	ID                    int64     `json:"id"`
	IsBackup              bool      `json:"isBackup"`
	LastAnnouncePeerCount int64     `json:"lastAnnouncePeerCount"`
	LastAnnounceResult    string    `json:"lastAnnounceResult"`
	LastAnnounceStartTime time.Time `json:"lastAnnounceStartTime"`
	LastAnnounceSucceeded bool      `json:"lastAnnounceSucceeded"`
	LastAnnounceTime      time.Time `json:"lastAnnounceTime"`
	LastAnnounceTimedOut  bool      `json:"lastAnnounceTimedOut"`
	LastScrapeResult      string    `json:"lastScrapeResult"`
	LastScrapeStartTime   time.Time `json:"lastScrapeStartTime"`
	LastScrapeSucceeded   bool      `json:"lastScrapeSucceeded"`
	LastScrapeTime        time.Time `json:"lastScrapeTime"`
	LastScrapeTimedOut    bool      `json:"lastScrapeTimedOut"` // should be boolean but number. Will be converter in UnmarshalJSON
	LeecherCount          int64     `json:"leecherCount"`
	NextAnnounceTime      time.Time `json:"nextAnnounceTime"`
	NextScrapeTime        time.Time `json:"nextScrapeTime"`
	Scrape                string    `json:"scrape"`
	ScrapeState           int64     `json:"scrapeState"`
	SiteName              string    `json:"sitename"`
	SeederCount           int64     `json:"seederCount"`
	Tier                  int64     `json:"tier"`
}

TrackerStats represent the extended data of a torrent's tracker.

func (TrackerStats) MarshalJSON

func (ts TrackerStats) MarshalJSON() (data []byte, err error)

MarshalJSON allows to convert back golang values to original payload values.

func (*TrackerStats) UnmarshalJSON

func (ts *TrackerStats) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON allows to convert timestamps to golang time.Time values.

type TransmissionFreeSpace

type TransmissionFreeSpace struct {
	Path      string `json:"path"`
	Size      int64  `json:"size-bytes"`
	TotalSize int64  `json:"total_size"` // RPC v17
}

TransmissionFreeSpace represents the freespace available in bytes for a specific path.

type Units

type Units struct {
	SpeedUnits  []string `json:"speed-units"`  // 4 strings: KB/s, MB/s, GB/s, TB/s
	SpeedBytes  int64    `json:"speed-bytes"`  // number of bytes in a KB (1000 for kB; 1024 for KiB)
	SizeUnits   []string `json:"size-units"`   // 4 strings: KB/s, MB/s, GB/s, TB/s
	SizeBytes   int64    `json:"size-bytes"`   // number of bytes in a KB (1000 for kB; 1024 for KiB)
	MemoryUnits []string `json:"memory-units"` // 4 strings: KB/s, MB/s, GB/s, TB/s
	MemoryBytes int64    `json:"memory-bytes"` // number of bytes in a KB (1000 for kB; 1024 for KiB)
}

Units is subset of SessionArguments.

func (*Units) GetMemory

func (u *Units) GetMemory() (memory cunits.Bits)

GetMemory returns the memory in a handy format

func (*Units) GetSize

func (u *Units) GetSize() (size cunits.Bits)

GetSize returns the size in a handy format

func (*Units) GetSpeed

func (u *Units) GetSpeed() (speed cunits.Bits)

GetSpeed returns the speed in a handy format

Jump to

Keyboard shortcuts

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