Documentation ¶
Index ¶
- Constants
- Variables
- type AddTorrentArg
- type Client
- func (c *Client) Add(filename string) (*Torrent, error)
- func (c *Client) AddTorrent(args AddTorrentArg) (*Torrent, error)
- func (c *Client) BlocklistUpdate() (int, error)
- func (c *Client) Do(req *http.Request, retry bool) (*http.Response, error)
- func (c *Client) FreeSpace(path string) (int, error)
- func (c *Client) GetTorrentMap() (TorrentMap, error)
- func (c *Client) GetTorrents() ([]*Torrent, error)
- func (c *Client) PortTest() (bool, error)
- func (c *Client) QueueMoveBottom(torrents []*Torrent) error
- func (c *Client) QueueMoveDown(torrents []*Torrent) error
- func (c *Client) QueueMoveTop(torrents []*Torrent) error
- func (c *Client) QueueMoveUp(torrents []*Torrent) error
- func (c *Client) RemoveTorrents(torrents []*Torrent, removeData bool) error
- type Config
- type File
- type FileStats
- type Peers
- type PeersFrom
- type Request
- type Response
- type Session
- type SetSessionArgs
- type SetTorrentArg
- type StatisticDetail
- type Statistics
- type Torrent
- func (t *Torrent) PathRename(path string, newPath string) error
- func (t *Torrent) Reannounce() error
- func (t *Torrent) Set(arg SetTorrentArg) error
- func (t *Torrent) SetLocation(path string, move bool) error
- func (t *Torrent) Start() error
- func (t *Torrent) StartNow() error
- func (t *Torrent) Stop() error
- func (t *Torrent) Update() error
- func (t *Torrent) Verify() error
- type TorrentMap
- type Torrents
- type TrackerStats
- type Trackers
- type Units
Constants ¶
const ( // StatusStopped stopped StatusStopped = 0 // StatusCheckPending check pending StatusCheckPending = 1 // StatusChecking checking StatusChecking = 2 // StatusDownloadPending download pending StatusDownloadPending = 3 // StatusDownloading downloading StatusDownloading = 4 // StatusSeedPending seed pending StatusSeedPending = 5 // StatusSeeding seeding StatusSeeding = 6 )
Variables ¶
var ( // ErrDuplicateTorrent returned when the torrent is already added ErrDuplicateTorrent = errors.New("Torrent already added") )
Functions ¶
This section is empty.
Types ¶
type AddTorrentArg ¶
type AddTorrentArg struct { //The format of the "cookies" should be NAME=CONTENTS, where NAME is the //cookie name and CONTENTS is what the cookie should contain. Set multiple //cookies like this: "name1=content1; name2=content2;" etc. //<http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTCOOKIE> Cookies string `json:"cookies,omitempty"` // DownloadDir path to download the torrent to DownloadDir string `json:"download-dir,omitempty"` // Filename filename or URL of the .torrent file Filename string `json:"filename,omitempty"` // Metainfo base64-encoded .torrent content Metainfo string `json:"metainfo,omitempty"` // Paused if true add torrent paused default false Paused bool `json:"paused,omitempty"` // PeerLimit maximum number of peers PeerLimit int `json:"peer-limit,omitempty"` // BandwidthPriority torrent's bandwidth BandwidthPriority int `json:",omitempty"` FilesWanted []int `json:"files-wanted,omitempty"` FilesUnwanted []int `json:"files-unwanted,omitempty"` PriorityHigh []int `json:"priority-high,omitempty"` PriorityLow []int `json:"priority-low,omitempty"` PriorityNormal []int `json:"priority-normal,omitempty"` }
AddTorrentArg params for Client.AddTorrent
type Client ¶
Client transmission client
func (*Client) AddTorrent ¶
func (c *Client) AddTorrent(args AddTorrentArg) (*Torrent, error)
AddTorrent add torrent from filename or metadata see AddTorrentArg for arguments
func (*Client) BlocklistUpdate ¶
BlocklistUpdate update blocklist and return blocklist rules size
func (*Client) Do ¶
Do low level function for interact with transmission only take care of authentification and session id
func (*Client) FreeSpace ¶
FreeSpace tests how much free space is available in a client-specified folder.
func (*Client) GetTorrentMap ¶
func (c *Client) GetTorrentMap() (TorrentMap, error)
GetTorrentMap returns a map of torrents indexed by torrent hash.
func (*Client) GetTorrents ¶
GetTorrents return list of torrent
func (*Client) PortTest ¶
PortTest tests to see if your incoming peer port is accessible from the outside world.
func (*Client) QueueMoveBottom ¶
QueueMoveBottom moves torrents to botton of the queue
func (*Client) QueueMoveDown ¶
QueueMoveDown moves torrents down in the queue
func (*Client) QueueMoveTop ¶
QueueMoveTop moves torrents to top of the queue
func (*Client) QueueMoveUp ¶
QueueMoveUp moves torrents up in the queue
type Config ¶
type Config struct { Address string User string Password string // HTTPClient specify your own if you need default: http.Client HTTPClient *http.Client }
Config used to configure transmission client
type Peers ¶
type Peers struct { Address string ClientName string ClientIsChoked bool ClientIsInterested bool FlagStr string IsDownloadingFrom bool IsEncrypted bool IsIncoming bool IsUploadingTo bool IsUTP bool PeerIsChoked bool PeerIsInterested bool Port int Progress float64 RateToClient int RateToPeer int }
Peers transmission API response
type PeersFrom ¶
type PeersFrom struct { FromCache int FromDht int FromIncoming int FromLpd int FromLtep int FromPex int FromTracker int }
PeersFrom transmission API response
type Request ¶
type Request struct { Method string `json:"method"` Arguments interface{} `json:"arguments"` }
Request object for API call
type Response ¶
type Response struct { Arguments interface{} `json:"arguments"` Result string `json:"result"` }
Response object for API call response
type Session ¶
type Session struct { Client *Client `json:"-"` AltSpeedDown int `jsonn:"alt-speed-down"` AltSpeedEnabled bool `json:"alt-speed-enabled"` AltSpeedTimeBegin int `json:"alt-speed-time-begin"` AltSpeedTimeEnabled bool `json:"alt-speed-time-enabled"` AltSpeedTimeEnd int `json:"alt-speed-time-end"` AltSpeedTimeDay int `json:"alt-speed-time-day"` AltSpeedUp int `json:"alt-speed-up"` BlocklistURL string `json:"blocklist-url"` BlocklistEnabled bool `json:"blocklist-enabled"` BlocklistSize int `json:"blocklist-size"` CacheSizeMb int `json:"cache-size-mb"` ConfigDir string `json:"config-dir"` DownloadDir string `json:"download-dir"` DownloadQueueSize int `json:"download-queue-size"` DownloadQueueEnabled bool `json:"download-queue-enabled"` DhtEnabled bool `json:"dht-enabled"` 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"` PexEnabled bool `json:"pex-enabled"` PeerPort int `json:"peer-port"` PeerPortRandomOnStart bool `json:"peer-port-random-on-start"` 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"` ScriptTorrentDoneFilename string `json:"script-torrent-done-filename"` ScriptTorrentDoneEnabled bool `json:"script-torrent-done-enabled"` SeedRatioLimit float64 `json:"seedRatioLimit"` SeedRatioLimited bool `json:"seedRatioLimited"` SeedQueueSize int `json:"seed-queue-size"` SeedQueueEnabled bool `json:"seed-queue-enabled"` SpeedLimitDown int `json:"speed-limit-down"` SpeedLimitDownEnabled bool `json:"speed-limit-down-enabled"` SpeedLimitUp int `json:"speed-limit-up"` SpeedLimitUpEnabled bool `json:"speed-limit-up-enabled"` StartAddedTorrents bool `json:"start-added-torrents"` TrashOriginalTorrentFiles bool `json:"trash-original-torrent-files"` Units *Units `json:"units"` UtpEnabled bool `json:"utp-enabled"` Version string `json:"version"` }
Session object contain information about transmission session and interact with it
func (*Session) Set ¶
func (s *Session) Set(args SetSessionArgs) error
Set set session params see SetSessionArgs
func (*Session) Stats ¶
func (s *Session) Stats() (Statistics, error)
Stats return session statistics
type SetSessionArgs ¶
type SetSessionArgs struct { AltSpeedDown int `json:"alt-speed-down,omitempty"` AltSpeedEnabled bool `json:"alt-speed-enabled,omitempty"` AltSpeedTimeBegin int `json:"alt-speed-time-begin,omitempty"` AltSpeedTimeEnabled bool `json:"alt-speed-time-enabled,omitempty"` AltSpeedTimeEnd int `json:"alt-speed-time-end,omitempty"` AltSpeedTimeDay int `json:"alt-speed-time-day,omitempty"` AltSpeedUp int `json:"alt-speed-up,omitempty"` BlocklistURL string `json:"blocklist-url,omitempty"` BlocklistEnabled bool `json:"blocklist-enabled,omitempty"` CacheSizeMb int `json:"cache-size-mb,omitempty"` DownloadDir string `json:"download-dir,omitempty"` DownloadQueueSize int `json:"download-queue-size,omitempty"` DownloadQueueEnabled bool `json:"download-queue-enabled,omitempty"` DhtEnabled bool `json:"dht-enabled,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"` PexEnabled bool `json:"pex-enabled,omitempty"` PeerPort int `json:"peer-port,omitempty"` PeerPortRandomOnStart bool `json:"peer-port-random-on-start,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"` ScriptTorrentDoneFilename string `json:"script-torrent-done-filename,omitempty"` ScriptTorrentDoneEnabled bool `json:"script-torrent-done-enabled,omitempty"` SeedRatioLimit float64 `json:"seedRatioLimit,omitempty"` SeedRatioLimited bool `json:"seedRatioLimited,omitempty"` SeedQueueSize int `json:"seed-queue-size,omitempty"` SeedQueueEnabled bool `json:"seed-queue-enabled,omitempty"` SpeedLimitDown int `json:"speed-limit-down,omitempty"` SpeedLimitDownEnabled bool `json:"speed-limit-down-enabled,omitempty"` SpeedLimitUp int `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"` Units *Units `json:"units,omitempty"` UtpEnabled bool `json:"utp-enabled,omitempty"` }
SetSessionArgs arguments for Session.Set
type SetTorrentArg ¶
type SetTorrentArg struct { BandwidthPriority int `json:"bandwidthPriority,omitempty"` DownloadLimit int `json:"downloadLimit,omitempty"` DownloadLimited bool `json:"downloadLimited,omitempty"` FilesWanted []int `json:"files-wanted,omitempty"` FilesUnwanted []int `json:"files-unwanted,omitempty"` HonorsSessionLimits bool `json:"honorsSessionLimits,omitempty"` Ids int `json:"ids"` 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"` TrackerAdd []string `json:"trackerAdd,omitempty"` TrackerRemove []int `json:"trackerRemove,omitempty"` // TrackerReplace `json:"trackerReplace,omitempty"` UploadLimit int `json:"uploadLimit,omitempty"` UploadLimited bool `json:"uploadLimited,omitempty"` }
SetTorrentArg arguments for Torrent.Set method
type StatisticDetail ¶
type StatisticDetail struct { UploadedBytes int64 DownloadedBytes int64 FilesAdded int64 SessionCount int64 SecondsActive int64 }
StatisticDetail represent statistics details
type Statistics ¶
type Statistics struct { ActiveTorrentCount int DownloadSpeed int PausedTorrentCount int TorrentCount int UploadSpeed int CumulativeStats *StatisticDetail `json:"cumulative-stats"` CurrentStats *StatisticDetail `json:"current-stats"` }
Statistics represent session statistics
type Torrent ¶
type Torrent struct { Client *Client `json:"-"` ActivityDate int AddedDate int BandwidthPriority int Comment string CorruptEver int64 Creator string DateCreated int DesiredAvailable int64 DoneDate int DownloadDir string DownloadedEver int64 DownloadLimit int DownloadLimited bool Error int ErrorString string Eta int EtaIdle int Files *[]File FileStats *[]FileStats HashString string HaveUnchecked int64 HaveValid int64 HonorsSessionLimits bool ID int IsFinished bool IsPrivate bool IsStalled bool Labels []string LeftUntilDone int64 MagnetLink string ManualAnnounceTime int MaxConnectedPeers int MetadataPercentComplete float64 Name string Peerlimit int Peers *[]Peers PeersConnected int PeersFrom PeersFrom PeersGettingFromUs int PeersSendingToUs int PercentDone float64 Pieces string PieceCount int PieceSize int Priorities []int QueuePosition int RateDownload int RateUpload int RecheckProgress float64 SecondsDownloading int SecondsSeeding int SeedIdleLimit int SeedIdleMode int SeedRatioLimit float64 SeedRatioMode int SizeWhenDone int64 StartDate int Status int Trackers *[]Trackers TrackerStats *[]TrackerStats TotalSize int64 TorrentFile string UploadedEver int64 UploadLimit int UploadLimited bool UploadRatio float64 Wanted []int Webseeds []string WebseedsSendingToUs int }
Torrent represent a torrent present in transmission
func (*Torrent) PathRename ¶
PathRename renames a file or directory in a torrent.
func (*Torrent) Set ¶
func (t *Torrent) Set(arg SetTorrentArg) error
Set changes torrent param see SetTorrentArg
func (*Torrent) SetLocation ¶
SetLocation moves a Torrent move if true, move from previous location. otherwise, search "location" for files
type TorrentMap ¶
TorrentMap is a map of Torrents indexed by torrent hash.
type Torrents ¶
type Torrents struct {
Torrents []*Torrent `json:"torrents"`
}
Torrents a list of Torrents
type TrackerStats ¶
type TrackerStats struct { Announce string AnnounceState int DownloadCount int HasAnnounced bool HasScraped bool Host string ID int IsBackup bool LastAnnouncePeerCount int LastAnnounceResult string LastAnnounceStartTime int LastAnnounceSucceeded bool LastAnnounceTime int LastAnnounceTimedOut bool LastScrapeResult string LastScrapeStartTime int LastScrapeSucceeded bool LastScrapeTime int LastScrapeTimedOut bool LeecherCount int NextAnnounceTime int NextScrapeTim int Scrap string ScrapeState int SeederCount int Tier int }
TrackerStats transmission API response