transmission

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: MIT Imports: 14 Imported by: 3 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

transmission

A modern, idiomatic Go client library for the Transmission BitTorrent client RPC API.

Go Reference

Features

  • Full Transmission RPC Coverage: Supports Transmission 2.x, 3.x, and 4.x.
  • Context Support: Complete context.Context propagation on all methods.
  • Thread-safe & Resilient: Handles CSRF session token (X-Transmission-Session-Id) negotiation and HTTP 409 re-authentication automatically with thread-safe read/write locking.
  • Rich Methods:
    • Torrents: Start, StartNow, Stop, Verify, Reannounce, SetLocation, RenamePath, Remove, Add (Magnet/URL/File/Bytes), Set (Speed limits, Priority, Wanted files, Labels, Ratio).
    • Session: Session settings, Alternative Speed Limits ("Turtle Mode"), Download Directory, Speed Limits, Daemon Stats, Shutdown.
    • Utilities: Free space check (FreeSpace), Port testing (PortTest), Blocklist update (UpdateBlocklist), Queue manipulation (QueueMoveTop, QueueMoveUp, QueueMoveDown, QueueMoveBottom).
  • Zero External Dependencies: Uses only standard library Go.

Installation

go get github.com/pyed/transmission

Quick Start

package main

import (
	"context"
	"fmt"
	"log"

	"github.com/pyed/transmission"
)

func main() {
	ctx := context.Background()

	// Initialize client
	client, err := transmission.New("http://localhost:9091/transmission/rpc", "username", "password")
	if err != nil {
		log.Fatalf("failed to connect: %v", err)
	}

	// List torrents
	torrents, err := client.GetTorrents(ctx)
	if err != nil {
		log.Fatalf("failed to get torrents: %v", err)
	}

	for _, t := range torrents {
		fmt.Printf("[%d] %s - %s (%.1f%%)\n", t.ID, t.Name, t.TorrentStatus(), t.PercentDone*100)
	}

	// Add a torrent
	added, err := client.AddTorrentByURL(ctx, "magnet:?xt=urn:btih:...")
	if err != nil {
		log.Fatalf("failed to add torrent: %v", err)
	}
	fmt.Printf("Added torrent: %s (ID: %d)\n", added.Name, added.ID)

	// Toggle Turtle Mode
	if err := client.SetAltSpeedEnabled(ctx, true); err != nil {
		log.Fatalf("failed to enable turtle mode: %v", err)
	}

	// Check free disk space
	free, total, err := client.FreeSpace(ctx, "/downloads")
	if err == nil {
		fmt.Printf("Free disk space: %d GB / %d GB\n", free/(1024*1024*1024), total/(1024*1024*1024))
	}
}

License

MIT

Documentation

Index

Constants

View Source
const (
	StatusStopped         = 0 // Torrent is stopped
	StatusCheckPending    = 1 // Queued to check files
	StatusChecking        = 2 // Checking files
	StatusDownloadPending = 3 // Queued to download
	StatusDownloading     = 4 // Downloading
	StatusSeedPending     = 5 // Queued to seed
	StatusSeeding         = 6 // Seeding
)

Torrent Status constants (matches libtransmission tr_stat status)

View Source
const (
	PriorityLow    = -1
	PriorityNormal = 0
	PriorityHigh   = 1
)

Bandwidth Priority constants

View Source
const (
	SeedRatioModeGlobal    = 0 // Follow global ratio limit
	SeedRatioModeCustom    = 1 // Follow per-torrent ratio limit
	SeedRatioModeUnlimited = 2 // Unlimited seed ratio
)

SeedRatioMode constants

View Source
const (
	SeedIdleModeGlobal    = 0 // Follow global idle seeding limit
	SeedIdleModeCustom    = 1 // Follow per-torrent idle seeding limit
	SeedIdleModeUnlimited = 2 // Unlimited idle seeding
)

SeedIdleMode constants

View Source
const (
	ErrorNone           = 0 // No error
	ErrorTrackerWarning = 1 // Tracker warning
	ErrorTrackerError   = 2 // Tracker error
	ErrorLocalError     = 3 // Local filesystem or permission error
)

Error codes reported by Transmission

Variables

This section is empty.

Functions

This section is empty.

Types

type AddTorrentOptions

type AddTorrentOptions struct {
	Cookies           *string  `json:"cookies,omitempty"`
	DownloadDir       *string  `json:"download-dir,omitempty"`
	Filename          *string  `json:"filename,omitempty"`
	MetaInfo          *string  `json:"metainfo,omitempty"`
	Paused            *bool    `json:"paused,omitempty"`
	PeerLimit         *int     `json:"peer-limit,omitempty"`
	BandwidthPriority *int     `json:"bandwidthPriority,omitempty"`
	FilesUnwanted     []int    `json:"files-unwanted,omitempty"`
	FilesWanted       []int    `json:"files-wanted,omitempty"`
	PriorityHigh      []int    `json:"priority-high,omitempty"`
	PriorityLow       []int    `json:"priority-low,omitempty"`
	PriorityNormal    []int    `json:"priority-normal,omitempty"`
	Labels            []string `json:"labels,omitempty"`
}

AddTorrentOptions defines options for adding a new torrent via torrent-add.

type ApiClient

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

ApiClient is a backwards-compatible wrapper.

func NewClient

func NewClient(url, username, password string) *ApiClient

NewClient is a backwards-compatible constructor.

func (*ApiClient) Post

func (ac *ApiClient) Post(body string) ([]byte, error)

type Client

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

Client interacts with the Transmission RPC API.

func New

func New(rawURL, username, password string, opts ...Option) (*Client, error)

New creates a new Transmission RPC Client.

func (*Client) AddTorrent

func (c *Client) AddTorrent(ctx context.Context, opt AddTorrentOptions) (*TorrentAdded, error)

AddTorrent adds a torrent using custom AddTorrentOptions.

func (*Client) AddTorrentByData

func (c *Client) AddTorrentByData(ctx context.Context, data []byte) (*TorrentAdded, error)

AddTorrentByData adds a torrent from raw .torrent bytes.

func (*Client) AddTorrentByFile

func (c *Client) AddTorrentByFile(ctx context.Context, filePath string) (*TorrentAdded, error)

AddTorrentByFile adds a torrent by reading a local .torrent file.

func (*Client) AddTorrentByURL

func (c *Client) AddTorrentByURL(ctx context.Context, url string) (*TorrentAdded, error)

AddTorrentByURL adds a torrent from a magnet link or HTTP/HTTPS URL.

func (*Client) CloseSession

func (c *Client) CloseSession(ctx context.Context) error

CloseSession cleanly shuts down the Transmission daemon.

func (*Client) DeleteTorrent

func (c *Client) DeleteTorrent(id int, deleteData bool) (string, error)

DeleteTorrent deletes a torrent by ID and returns the torrent name (backwards-compatible).

func (*Client) Execute

func (c *Client) Execute(ctx context.Context, method string, args any, result any) error

Execute performs a JSON-RPC request to the Transmission daemon with automatic CSRF token renewal.

func (*Client) ExecuteAddCommand

func (c *Client) ExecuteAddCommand(addCmd *Command) (TorrentAdded, error)

ExecuteAddCommand is preserved for backwards compatibility.

func (*Client) ExecuteCommand

func (c *Client) ExecuteCommand(cmd *Command) (*Command, error)

ExecuteCommand executes a legacy Command.

func (*Client) FreeSpace

func (c *Client) FreeSpace(ctx context.Context, path string) (freeBytes int64, totalBytes int64, err error)

FreeSpace checks remaining and total storage space for the given filesystem path.

func (*Client) GetRecentlyActive

func (c *Client) GetRecentlyActive(ctx context.Context, fields ...string) (active Torrents, removedIDs []int, err error)

GetRecentlyActive fetches only torrents that were recently active, plus IDs of recently removed torrents.

func (*Client) GetSession

func (c *Client) GetSession(ctx context.Context) (*Session, error)

GetSession retrieves the current global session settings.

func (*Client) GetStats

func (c *Client) GetStats(ctx ...context.Context) (*Stats, error)

GetStats returns current and cumulative Transmission statistics.

func (*Client) GetTorrent

func (c *Client) GetTorrent(id int, ctx ...context.Context) (*Torrent, error)

GetTorrent returns a single torrent by ID.

func (*Client) GetTorrents

func (c *Client) GetTorrents(ctx ...context.Context) (Torrents, error)

GetTorrents returns all torrents applying the currently configured sort order.

func (*Client) GetTorrentsByIDs

func (c *Client) GetTorrentsByIDs(ctx context.Context, ids []int, fields ...string) (Torrents, error)

GetTorrentsByIDs fetches specified torrents with custom field selection.

func (*Client) PortTest

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

PortTest checks if Transmission's incoming peer port is open and reachable from the internet.

func (*Client) QueueMoveBottom

func (c *Client) QueueMoveBottom(ctx context.Context, ids ...int) error

QueueMoveBottom moves the specified torrents to the bottom of the queue.

func (*Client) QueueMoveDown

func (c *Client) QueueMoveDown(ctx context.Context, ids ...int) error

QueueMoveDown moves the specified torrents down by one position in the queue.

func (*Client) QueueMoveTop

func (c *Client) QueueMoveTop(ctx context.Context, ids ...int) error

QueueMoveTop moves the specified torrents to the top of the queue.

func (*Client) QueueMoveUp

func (c *Client) QueueMoveUp(ctx context.Context, ids ...int) error

QueueMoveUp moves the specified torrents up by one position in the queue.

func (*Client) ReannounceTorrents

func (c *Client) ReannounceTorrents(ctx context.Context, ids ...int) error

ReannounceTorrents forces an immediate tracker re-announce for the given torrents.

func (*Client) RemoveTorrents

func (c *Client) RemoveTorrents(ctx context.Context, deleteLocalData bool, ids ...int) error

RemoveTorrents deletes one or more torrents and optionally removes downloaded files.

func (*Client) RenameTorrentPath

func (c *Client) RenameTorrentPath(ctx context.Context, id int, path, newName string) (*RenameResult, error)

RenameTorrentPath renames a file or directory within a torrent.

func (*Client) SetAltSpeedEnabled

func (c *Client) SetAltSpeedEnabled(ctx context.Context, enabled bool) error

SetAltSpeedEnabled toggles alternative speed limits ("Turtle Mode").

func (*Client) SetDownloadDir

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

SetDownloadDir sets the global default download directory.

func (*Client) SetSession

func (c *Client) SetSession(ctx context.Context, opt SessionSetOptions) error

SetSession updates global session settings.

func (*Client) SetSort

func (c *Client) SetSort(st Sorting)

SetSort sets the default sorting for GetTorrents calls on the client.

func (*Client) SetSpeedLimit

func (c *Client) SetSpeedLimit(ctx context.Context, limitType SpeedLimitType, limitKB uint) error

SetSpeedLimit sets the global upload or download speed limit in KB/s.

func (*Client) SetTorrent

func (c *Client) SetTorrent(ctx context.Context, ids []int, opt TorrentSetOptions) error

SetTorrent mutates settings for the specified torrents.

func (*Client) SetTorrentLocation

func (c *Client) SetTorrentLocation(ctx context.Context, location string, move bool, ids ...int) error

SetTorrentLocation sets a new location path for torrents and optionally moves data files.

func (*Client) StartAll

func (c *Client) StartAll(ctx ...context.Context) error

StartAll starts all torrents.

func (*Client) StartTorrent

func (c *Client) StartTorrent(id int) (string, error)

StartTorrent starts a single torrent by ID (backwards-compatible signature).

func (*Client) StartTorrents

func (c *Client) StartTorrents(ctx context.Context, ids ...int) error

StartTorrents starts one or more torrents by ID.

func (*Client) StartTorrentsNow

func (c *Client) StartTorrentsNow(ctx context.Context, ids ...int) error

StartTorrentsNow starts one or more torrents immediately disregarding queue position.

func (*Client) StopAll

func (c *Client) StopAll(ctx ...context.Context) error

StopAll stops all torrents.

func (*Client) StopTorrent

func (c *Client) StopTorrent(id int) (string, error)

StopTorrent stops a single torrent by ID (backwards-compatible signature).

func (*Client) StopTorrents

func (c *Client) StopTorrents(ctx context.Context, ids ...int) error

StopTorrents stops one or more torrents by ID.

func (*Client) UpdateBlocklist

func (c *Client) UpdateBlocklist(ctx context.Context) (int, error)

UpdateBlocklist updates the blocklist from the configured blocklist-url and returns the rule count.

func (*Client) VerifyAll

func (c *Client) VerifyAll(ctx ...context.Context) error

VerifyAll verifies all torrents.

func (*Client) VerifyTorrent

func (c *Client) VerifyTorrent(id int) (string, error)

VerifyTorrent verifies a single torrent by ID (backwards-compatible signature).

func (*Client) VerifyTorrents

func (c *Client) VerifyTorrents(ctx context.Context, ids ...int) error

VerifyTorrents verifies file checksums for one or more torrents.

func (*Client) Version

func (c *Client) Version() string

Version returns Transmission daemon version string.

type Command

type Command struct {
	Method    string    `json:"method,omitempty"`
	Arguments arguments `json:"arguments,omitempty"`
	Result    string    `json:"result,omitempty"`
}

Command is preserved for backwards compatibility.

func NewAddCmd

func NewAddCmd() *Command

NewAddCmd creates a legacy add command.

func NewAddCmdByFile

func NewAddCmdByFile(file string) (*Command, error)

NewAddCmdByFile creates a legacy add command by loading a file.

func NewAddCmdByFilename

func NewAddCmdByFilename(filename string) *Command

NewAddCmdByFilename creates a legacy add command with filename.

func NewAddCmdByURL

func NewAddCmdByURL(url string) *Command

NewAddCmdByURL creates a legacy add command from URL or magnet.

func NewGetTorrentsCmd

func NewGetTorrentsCmd() *Command

NewGetTorrentsCmd is preserved for backwards compatibility.

func NewSessionSetCommand

func NewSessionSetCommand() *Command

NewSessionSetCommand is preserved for backwards compatibility.

func NewSpeedLimitCommand

func NewSpeedLimitCommand(limitType SpeedLimitType, limit uint) *Command

NewSpeedLimitCommand creates a legacy Command to set speed limits.

func (*Command) SetDownloadDir

func (cmd *Command) SetDownloadDir(dir string)

SetDownloadDir mutates legacy Command.

type File

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

File represents a file inside a torrent.

type FileStat

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

FileStat represents individual file download status.

type Option

type Option func(*Client)

Option configures a Transmission Client.

func WithCustomHeader

func WithCustomHeader(key, value string) Option

WithCustomHeader adds a default HTTP header to all requests.

func WithHTTPClient

func WithHTTPClient(httpClient *http.Client) Option

WithHTTPClient sets a custom http.Client.

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout sets the default request timeout.

type Peer

type Peer struct {
	Address            string  `json:"address"`
	ClientName         string  `json:"clientName"`
	ClientIsChoked     bool    `json:"clientIsChoked"`
	ClientIsInterested bool    `json:"clientIsInterested"`
	FlagStr            string  `json:"flagStr"`
	IsDownloadingFrom  bool    `json:"isDownloadingFrom"`
	IsEncrypted        bool    `json:"isEncrypted"`
	IsIncoming         bool    `json:"isIncoming"`
	IsUploadingTo      bool    `json:"isUploadingTo"`
	PeerIsChoked       bool    `json:"peerIsChoked"`
	PeerIsInterested   bool    `json:"peerIsInterested"`
	Port               int     `json:"port"`
	Progress           float64 `json:"progress"`
	RateToClient       uint64  `json:"rateToClient"`
	RateToPeer         uint64  `json:"rateToPeer"`
}

Peer represents connected peer information.

type RenameResult

type RenameResult struct {
	Path string `json:"path"`
	Name string `json:"name"`
	ID   int    `json:"id"`
}

type Session

type Session struct {
	AltSpeedDown               int64   `json:"alt-speed-down"`
	AltSpeedEnabled            bool    `json:"alt-speed-enabled"`
	AltSpeedTimeBegin          int     `json:"alt-speed-time-begin"`
	AltSpeedTimeDay            int     `json:"alt-speed-time-day"`
	AltSpeedTimeEnabled        bool    `json:"alt-speed-time-enabled"`
	AltSpeedTimeEnd            int     `json:"alt-speed-time-end"`
	AltSpeedUp                 int64   `json:"alt-speed-up"`
	BlocklistEnabled           bool    `json:"blocklist-enabled"`
	BlocklistSize              int     `json:"blocklist-size"`
	BlocklistURL               string  `json:"blocklist-url"`
	CacheSizeMB                int     `json:"cache-size-mb"`
	ConfigDir                  string  `json:"config-dir"`
	DefaultTrackers            string  `json:"default-trackers"`
	DHTEnabled                 bool    `json:"dht-enabled"`
	DownloadDir                string  `json:"download-dir"`
	DownloadDirFreeSpace       int64   `json:"download-dir-free-space"`
	DownloadQueueEnabled       bool    `json:"download-queue-enabled"`
	DownloadQueueSize          int     `json:"download-queue-size"`
	Encryption                 string  `json:"encryption"`
	IdleSeedingLimit           int     `json:"idle-seeding-limit"`
	IdleSeedingLimitEnabled    bool    `json:"idle-seeding-limit-enabled"`
	IncompleteDir              string  `json:"incomplete-dir"`
	IncompleteDirEnabled       bool    `json:"incomplete-dir-enabled"`
	LPDEnabled                 bool    `json:"lpd-enabled"`
	PeerLimitGlobal            int     `json:"peer-limit-global"`
	PeerLimitPerTorrent        int     `json:"peer-limit-per-torrent"`
	PeerPort                   int     `json:"peer-port"`
	PeerPortRandomOnStart      bool    `json:"peer-port-random-on-start"`
	PexEnabled                 bool    `json:"pex-enabled"`
	PortForwardingEnabled      bool    `json:"port-forwarding-enabled"`
	QueueStalledEnabled        bool    `json:"queue-stalled-enabled"`
	QueueStalledMinutes        int     `json:"queue-stalled-minutes"`
	RenamePartialFiles         bool    `json:"rename-partial-files"`
	RPCVersion                 int     `json:"rpc-version"`
	RPCVersionMinimum          int     `json:"rpc-version-minimum"`
	RPCVersionSemver           string  `json:"rpc-version-semver"`
	ScriptTorrentAddedEnabled  bool    `json:"script-torrent-added-enabled"`
	ScriptTorrentAddedFilename string  `json:"script-torrent-added-filename"`
	ScriptTorrentDoneEnabled   bool    `json:"script-torrent-done-enabled"`
	ScriptTorrentDoneFilename  string  `json:"script-torrent-done-filename"`
	SeedQueueEnabled           bool    `json:"seed-queue-enabled"`
	SeedQueueSize              int     `json:"seed-queue-size"`
	SeedRatioLimit             float64 `json:"seedRatioLimit"`
	SeedRatioLimited           bool    `json:"seedRatioLimited"`
	SessionID                  string  `json:"session-id"`
	SpeedLimitDown             int64   `json:"speed-limit-down"`
	SpeedLimitDownEnabled      bool    `json:"speed-limit-down-enabled"`
	SpeedLimitUp               int64   `json:"speed-limit-up"`
	SpeedLimitUpEnabled        bool    `json:"speed-limit-up-enabled"`
	StartAddedTorrents         bool    `json:"start-added-torrents"`
	TrashOriginalTorrentFiles  bool    `json:"trash-original-torrent-files"`
	UTPEnabled                 bool    `json:"utp-enabled"`
	Version                    string  `json:"version"`
}

Session represents global Transmission session settings.

type SessionSetOptions

type SessionSetOptions struct {
	AltSpeedDown               *int64   `json:"alt-speed-down,omitempty"`
	AltSpeedEnabled            *bool    `json:"alt-speed-enabled,omitempty"`
	AltSpeedTimeBegin          *int     `json:"alt-speed-time-begin,omitempty"`
	AltSpeedTimeDay            *int     `json:"alt-speed-time-day,omitempty"`
	AltSpeedTimeEnabled        *bool    `json:"alt-speed-time-enabled,omitempty"`
	AltSpeedTimeEnd            *int     `json:"alt-speed-time-end,omitempty"`
	AltSpeedUp                 *int64   `json:"alt-speed-up,omitempty"`
	BlocklistEnabled           *bool    `json:"blocklist-enabled,omitempty"`
	BlocklistURL               *string  `json:"blocklist-url,omitempty"`
	CacheSizeMB                *int     `json:"cache-size-mb,omitempty"`
	DefaultTrackers            *string  `json:"default-trackers,omitempty"`
	DHTEnabled                 *bool    `json:"dht-enabled,omitempty"`
	DownloadDir                *string  `json:"download-dir,omitempty"`
	DownloadQueueEnabled       *bool    `json:"download-queue-enabled,omitempty"`
	DownloadQueueSize          *int     `json:"download-queue-size,omitempty"`
	Encryption                 *string  `json:"encryption,omitempty"`
	IdleSeedingLimit           *int     `json:"idle-seeding-limit,omitempty"`
	IdleSeedingLimitEnabled    *bool    `json:"idle-seeding-limit-enabled,omitempty"`
	IncompleteDir              *string  `json:"incomplete-dir,omitempty"`
	IncompleteDirEnabled       *bool    `json:"incomplete-dir-enabled,omitempty"`
	LPDEnabled                 *bool    `json:"lpd-enabled,omitempty"`
	PeerLimitGlobal            *int     `json:"peer-limit-global,omitempty"`
	PeerLimitPerTorrent        *int     `json:"peer-limit-per-torrent,omitempty"`
	PeerPort                   *int     `json:"peer-port,omitempty"`
	PeerPortRandomOnStart      *bool    `json:"peer-port-random-on-start,omitempty"`
	PexEnabled                 *bool    `json:"pex-enabled,omitempty"`
	PortForwardingEnabled      *bool    `json:"port-forwarding-enabled,omitempty"`
	QueueStalledEnabled        *bool    `json:"queue-stalled-enabled,omitempty"`
	QueueStalledMinutes        *int     `json:"queue-stalled-minutes,omitempty"`
	RenamePartialFiles         *bool    `json:"rename-partial-files,omitempty"`
	ScriptTorrentAddedEnabled  *bool    `json:"script-torrent-added-enabled,omitempty"`
	ScriptTorrentAddedFilename *string  `json:"script-torrent-added-filename,omitempty"`
	ScriptTorrentDoneEnabled   *bool    `json:"script-torrent-done-enabled,omitempty"`
	ScriptTorrentDoneFilename  *string  `json:"script-torrent-done-filename,omitempty"`
	SeedQueueEnabled           *bool    `json:"seed-queue-enabled,omitempty"`
	SeedQueueSize              *int     `json:"seed-queue-size,omitempty"`
	SeedRatioLimit             *float64 `json:"seedRatioLimit,omitempty"`
	SeedRatioLimited           *bool    `json:"seedRatioLimited,omitempty"`
	SpeedLimitDown             *int64   `json:"speed-limit-down,omitempty"`
	SpeedLimitDownEnabled      *bool    `json:"speed-limit-down-enabled,omitempty"`
	SpeedLimitUp               *int64   `json:"speed-limit-up,omitempty"`
	SpeedLimitUpEnabled        *bool    `json:"speed-limit-up-enabled,omitempty"`
	StartAddedTorrents         *bool    `json:"start-added-torrents,omitempty"`
	TrashOriginalTorrentFiles  *bool    `json:"trash-original-torrent-files,omitempty"`
	UTPEnabled                 *bool    `json:"utp-enabled,omitempty"`
}

SessionSetOptions defines options for mutating global session settings.

type Sorting

type Sorting int

Sorting represents the sort criteria.

const (
	SortID Sorting = iota
	SortRevID
	SortName
	SortRevName
	SortAge
	SortRevAge
	SortSize
	SortRevSize
	SortProgress
	SortRevProgress
	SortDownSpeed
	SortRevDownSpeed
	SortUpSpeed
	SortRevUpSpeed
	SortDownloaded
	SortRevDownloaded
	SortUploaded
	SortRevUploaded
	SortRatio
	SortRevRatio
)

type SpeedLimitType

type SpeedLimitType string

SpeedLimitType defines whether a limit applies to download or upload

const (
	DownloadLimitType SpeedLimitType = "downloadlimit"
	UploadLimitType   SpeedLimitType = "uploadlimit"
)

type Stats

type Stats struct {
	ActiveTorrentCount int             `json:"activeTorrentCount"`
	CumulativeStats    cumulativeStats `json:"cumulative-stats"`
	CurrentStats       currentStats    `json:"current-stats"`
	DownloadSpeed      uint64          `json:"downloadSpeed"`
	PausedTorrentCount int             `json:"pausedTorrentCount"`
	TorrentCount       int             `json:"torrentCount"`
	UploadSpeed        uint64          `json:"uploadSpeed"`
}

Stats holds Transmission cumulative and session stats.

func (*Stats) CumulativeActiveTime

func (s *Stats) CumulativeActiveTime() string

func (*Stats) CurrentActiveTime

func (s *Stats) CurrentActiveTime() string

type Torrent

type Torrent struct {
	ActivityDate            int64          `json:"activityDate"`
	AddedDate               int64          `json:"addedDate"`
	BandwidthPriority       int            `json:"bandwidthPriority"`
	Comment                 string         `json:"comment"`
	CorruptEver             uint64         `json:"corruptEver"`
	Creator                 string         `json:"creator"`
	DateCreated             int64          `json:"dateCreated"`
	DesiredAvailable        uint64         `json:"desiredAvailable"`
	DoneDate                int64          `json:"doneDate"`
	DownloadDir             string         `json:"downloadDir"`
	DownloadedEver          uint64         `json:"downloadedEver"`
	DownloadLimit           int            `json:"downloadLimit"`
	DownloadLimited         bool           `json:"downloadLimited"`
	EditDate                int64          `json:"editDate"`
	Error                   int            `json:"error"`
	ErrorString             string         `json:"errorString"`
	Eta                     time.Duration  `json:"eta"`
	EtaIdle                 time.Duration  `json:"etaIdle"`
	FileCount               int            `json:"fileCount"`
	Files                   []File         `json:"files"`
	FileStats               []FileStat     `json:"fileStats"`
	HashString              string         `json:"hashString"`
	HaveUnchecked           uint64         `json:"haveUnchecked"`
	HaveValid               uint64         `json:"haveValid"`
	HonorsSessionLimits     bool           `json:"honorsSessionLimits"`
	ID                      int            `json:"id"`
	IsFinished              bool           `json:"isFinished"`
	IsPrivate               bool           `json:"isPrivate"`
	IsStalled               bool           `json:"isStalled"`
	Labels                  []string       `json:"labels"`
	LeftUntilDone           uint64         `json:"leftUntilDone"`
	ManualAnnounceTime      int64          `json:"manualAnnounceTime"`
	MaxConnectedPeers       int            `json:"maxConnectedPeers"`
	MetadataPercentComplete float64        `json:"metadataPercentComplete"`
	Name                    string         `json:"name"`
	PeerLimit               int            `json:"peer-limit"`
	Peers                   []Peer         `json:"peers"`
	PeersConnected          int            `json:"peersConnected"`
	PeersFrom               map[string]int `json:"peersFrom"`
	PeersGettingFromUs      int            `json:"peersGettingFromUs"`
	PeersSendingToUs        int            `json:"peersSendingToUs"`
	PercentComplete         float64        `json:"percentComplete"`
	PercentDone             float64        `json:"percentDone"`
	PieceCount              int            `json:"pieceCount"`
	PieceSize               int64          `json:"pieceSize"`
	Priorities              []int          `json:"priorities"`
	QueuePosition           int            `json:"queuePosition"`
	RateDownload            uint64         `json:"rateDownload"`
	RateUpload              uint64         `json:"rateUpload"`
	RecheckProgress         float64        `json:"recheckProgress"`
	SecondsDownloading      int            `json:"secondsDownloading"`
	SecondsSeeding          int            `json:"secondsSeeding"`
	SeedIdleLimit           int            `json:"seedIdleLimit"`
	SeedIdleMode            int            `json:"seedIdleMode"`
	SeedRatioLimit          float64        `json:"seedRatioLimit"`
	SeedRatioMode           int            `json:"seedRatioMode"`
	SizeWhenDone            uint64         `json:"sizeWhenDone"`
	StartDate               int64          `json:"startDate"`
	Status                  int            `json:"status"`
	Trackers                []Tracker      `json:"trackers"`
	TotalSize               uint64         `json:"totalSize"`
	TorrentFile             string         `json:"torrentFile"`
	UploadedEver            uint64         `json:"uploadedEver"`
	UploadLimit             int            `json:"uploadLimit"`
	UploadLimited           bool           `json:"uploadLimited"`
	UploadRatio             float64        `json:"uploadRatio"`
	Wanted                  []int          `json:"wanted"`
	Webseeds                []string       `json:"webseeds"`
	WebseedsSendingToUs     int            `json:"webseedsSendingToUs"`
}

Torrent represents all attributes of a Transmission torrent.

func (*Torrent) ETA

func (t *Torrent) ETA() string

ETA returns human-readable download ETA.

func (*Torrent) GetTrackers

func (t *Torrent) GetTrackers() string

GetTrackers returns announce URLs separated by newlines.

func (*Torrent) Have

func (t *Torrent) Have() uint64

Have returns total valid and unchecked downloaded bytes.

func (*Torrent) Ratio

func (t *Torrent) Ratio() string

Ratio returns formatted upload ratio.

func (*Torrent) TorrentStatus

func (t *Torrent) TorrentStatus() string

TorrentStatus returns human-readable status name.

type TorrentAdded

type TorrentAdded struct {
	HashString string `json:"hashString"`
	ID         int    `json:"id"`
	Name       string `json:"name"`
}

TorrentAdded represents the response from adding a torrent.

type TorrentSetOptions

type TorrentSetOptions struct {
	BandwidthPriority           *int     `json:"bandwidthPriority,omitempty"`
	DownloadLimit               *int     `json:"downloadLimit,omitempty"`
	DownloadLimited             *bool    `json:"downloadLimited,omitempty"`
	FilesUnwanted               []int    `json:"files-unwanted,omitempty"`
	FilesWanted                 []int    `json:"files-wanted,omitempty"`
	Group                       *string  `json:"group,omitempty"`
	HonorsSessionLimits         *bool    `json:"honorsSessionLimits,omitempty"`
	Labels                      []string `json:"labels,omitempty"`
	Location                    *string  `json:"location,omitempty"`
	PeerLimit                   *int     `json:"peer-limit,omitempty"`
	PriorityHigh                []int    `json:"priority-high,omitempty"`
	PriorityLow                 []int    `json:"priority-low,omitempty"`
	PriorityNormal              []int    `json:"priority-normal,omitempty"`
	QueuePosition               *int     `json:"queuePosition,omitempty"`
	SeedIdleLimit               *int     `json:"seedIdleLimit,omitempty"`
	SeedIdleMode                *int     `json:"seedIdleMode,omitempty"`
	SeedRatioLimit              *float64 `json:"seedRatioLimit,omitempty"`
	SeedRatioMode               *int     `json:"seedRatioMode,omitempty"`
	SequentialDownload          *bool    `json:"sequentialDownload,omitempty"`
	SequentialDownloadFromPiece *int     `json:"sequentialDownloadFromPiece,omitempty"`
	TrackerList                 *string  `json:"trackerList,omitempty"`
	UploadLimit                 *int     `json:"uploadLimit,omitempty"`
	UploadLimited               *bool    `json:"uploadLimited,omitempty"`
}

TorrentSetOptions specifies parameters for mutating torrents via torrent-set.

type Torrents

type Torrents []*Torrent

Torrents represents a slice of *Torrent with utility methods.

func (Torrents) GetIDs

func (t Torrents) GetIDs() []int

GetIDs returns a slice of all torrent IDs.

func (Torrents) SortAge

func (t Torrents) SortAge(reverse bool)

SortAge sorts torrents by added date.

func (Torrents) SortDownSpeed

func (t Torrents) SortDownSpeed(reverse bool)

SortDownSpeed sorts torrents by download speed.

func (Torrents) SortDownloaded

func (t Torrents) SortDownloaded(reverse bool)

SortDownloaded sorts torrents by total downloaded bytes ever.

func (Torrents) SortID

func (t Torrents) SortID(reverse bool)

SortID sorts torrents by ID.

func (Torrents) SortName

func (t Torrents) SortName(reverse bool)

SortName sorts torrents alphabetically by name (case-insensitive).

func (Torrents) SortProgress

func (t Torrents) SortProgress(reverse bool)

SortProgress sorts torrents by percent done.

func (Torrents) SortRatio

func (t Torrents) SortRatio(reverse bool)

SortRatio sorts torrents by upload ratio.

func (Torrents) SortSize

func (t Torrents) SortSize(reverse bool)

SortSize sorts torrents by size when done.

func (Torrents) SortUpSpeed

func (t Torrents) SortUpSpeed(reverse bool)

SortUpSpeed sorts torrents by upload speed.

func (Torrents) SortUploaded

func (t Torrents) SortUploaded(reverse bool)

SortUploaded sorts torrents by total uploaded bytes ever.

type Tracker

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

tracker represents tracker information for a torrent.

type TransmissionClient

type TransmissionClient = Client

TransmissionClient is an alias for Client for backwards compatibility.

Jump to

Keyboard shortcuts

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