utorrent

package
v0.0.0-...-270697f Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2018 License: GPL-3.0 Imports: 19 Imported by: 0

README

Utorrent Client

Compatible with uTorrent 3.4.5

Listing file
client := utorrent.Clients("{UTORRENT_URL}", "{ADMIN}", "{PASSWORD}")
Actions
// Start
func (T Torrent) Start(hash []string) error

// Stop
func (T Torrent) Stop(hash []string) error

// Pause
func (T Torrent) Pause(hash []string) error

// ForceStart
func (T Torrent) ForceStart(hash []string) error

// Unpause
func (T Torrent) Unpause(hash []string) error

// Recheck
func (T Torrent) Recheck(hash []string) error

// Remove
func (T Torrent) Remove(hash []string) error

// RemoveData
func (T Torrent) RemoveData(hash []string) error

Documentation

Index

Constants

View Source
const (
	TorrentStatusStarted         uint8 = 1 << 0
	TorrentStatusChecking        uint8 = 1 << 1
	TorrentStatusStartAfterCheck uint8 = 1 << 2
	TorrentStatusChecked         uint8 = 1 << 3
	TorrentStatusError           uint8 = 1 << 4
	TorrentStatusPaused          uint8 = 1 << 5
	TorrentStatusQueued          uint8 = 1 << 6
	TorrentStatusLoaded          uint8 = 1 << 7
)

UTorrent file status

Status:

1 = Started
2 = Checking
4 = Start after check
8 = Checked
16 = Error
32 = Paused
64 = Queued
128 = Loaded

Variables

View Source
var ByAdded = TorrentSortAsc(func(a, b *Torrent) bool {
	return a.DateAdded < b.DateAdded
})

ByAdded sort []Torrent by Added Date

View Source
var ByFinished = TorrentSortAsc(func(a, b *Torrent) bool {
	return a.DateCompleted < b.DateCompleted
})

ByFinished sort []Torrent by Finished Date

View Source
var ByName = TorrentSortAsc(func(a, b *Torrent) bool {
	return a.Name < b.Name
})

ByName sort []Torrent by Name

View Source
var ByProgress = TorrentSortAsc(func(a, b *Torrent) bool {
	return a.Progress < b.Progress
})

ByProgress sort []Torrent by progress

View Source
var ByQueueOrder = TorrentSortAsc(func(a, b *Torrent) bool {
	return a.TorrentQueueOrder < b.TorrentQueueOrder
})

ByQueueOrder sort []Torrent by Queue Order #

Functions

This section is empty.

Types

type ActionResult

type ActionResult struct {
	Build int64 `json:"build"`
}

ActionResult ...

type Client

type Client struct {
	BaseURL   string
	Username  string
	Password  string
	Token     string
	Authorize string
	// contains filtered or unexported fields
}

Client ...

func NewClient

func NewClient(baseURL string, username string, password string) (ut *Client, err error)

NewClient ...

func (*Client) AddFile

func (ut *Client) AddFile(torrentFile *os.File) (*ActionResult, error)

AddFile ..

func (*Client) AddURL

func (ut *Client) AddURL(torrenturl string) (*ActionResult, error)

AddURL ..

func (*Client) ForceStart

func (ut *Client) ForceStart(hash []string) error

ForceStart ...

func (*Client) ListFiles

func (ut *Client) ListFiles() (*ListFileResponse, error)

ListFiles ...

func (*Client) Pause

func (ut *Client) Pause(hash []string) error

Pause ...

func (*Client) Recheck

func (ut *Client) Recheck(hash []string) error

Recheck ...

func (*Client) Remove

func (ut *Client) Remove(hash []string) error

Remove ...

func (*Client) RemoveData

func (ut *Client) RemoveData(hash []string) error

RemoveData ...

func (*Client) SetLabel

func (ut *Client) SetLabel(hash, label string) error

SetLabel .

func (*Client) SetPriorityBottom

func (ut *Client) SetPriorityBottom(hash []string) error

SetPriorityBottom set priority to lowest.

func (*Client) SetPriorityTop

func (ut *Client) SetPriorityTop(hash []string) error

SetPriorityTop set priority to highest.

func (*Client) Start

func (ut *Client) Start(hash []string) error

Start ...

func (*Client) Stop

func (ut *Client) Stop(hash []string) error

Stop ...

func (*Client) Unpause

func (ut *Client) Unpause(hash []string) error

Unpause ...

type ClientError

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

ClientError ...

func (ClientError) Error

func (ce ClientError) Error() string

type Label

type Label struct {
	Name  string
	Count int
}

Label ...

type LabelFieldIndex

type LabelFieldIndex int

LabelFieldIndex ...

const (
	LabelIndexName  LabelFieldIndex = iota // 0: Name
	LabelIndexCount                        // 1: Count
)

type ListFileResponse

type ListFileResponse struct {
	Build      int       `json:"build"`    //Utorrent Client Build #
	Label      []Label   `json:"label"`    //Labels
	Torrents   []Torrent `json:"torrents"` //Torrents
	Torrentc   string    `json:"torrentc"` //Cache ID
	Rssfeeds   []string  `json:"rssfeeds"`
	Rssfilters []string  `json:"rssfilters"`
	Messages   []string  `json:"messages"`
}

ListFileResponse ...

type StatusMap

type StatusMap map[int]string

StatusMap ...

type Torrent

type Torrent struct {
	Hash              string
	Status            uint8
	Name              string
	Size              uint64
	Progress          uint32
	Downloaded        uint64
	Uploaded          uint64
	Ratio             uint64
	UlSpeed           uint32
	DlSpeed           uint32
	Eta               uint32
	Label             string
	PeerConnected     uint32
	PeerInSwarm       uint32
	SeedConnected     uint32
	SeedInSwarm       uint32
	Availability      uint32
	TorrentQueueOrder uint32
	Remaining         uint32
	DownloadURL       string
	StatusMessage     string
	DateAdded         uint64
	DateCompleted     uint64
	SavePath          string
}

Torrent ...

func (Torrent) AvailabilityRatio

func (t Torrent) AvailabilityRatio() float64

AvailabilityRatio Torrent.Availability devided by 65535

func (Torrent) Completed

func (t Torrent) Completed() bool

Completed return is torrent completed

func (Torrent) Error

func (t Torrent) Error() bool

func (Torrent) PercentCompleted

func (t Torrent) PercentCompleted() float64

PercentCompleted Torrent.Progress devided by 10..

func (Torrent) StatusStr

func (t Torrent) StatusStr() string

StatusStr ...

type TorrentCollection

type TorrentCollection []Torrent

TorrentCollection slice of Torrent

func (TorrentCollection) Sort

func (t TorrentCollection) Sort(by TorrentSortAsc, desc bool)

Sort sort []Torrent by Name

type TorrentFieldIndex

type TorrentFieldIndex int

TorrentFieldIndex ...

const (
	TorrentsIndexHash           TorrentFieldIndex = iota // 0: Hash (string),
	TorrentsIndexStatus                                  // 1: Status* (integer),
	TorrentsIndexName                                    // 2: Name (string),
	TorrentsIndexSize                                    // 3: Size (integer in bytes),
	TorrentsIndexProgress                                // 4: Percent Progress (integer in per mils),
	TorrentsIndexDownloaded                              // 5: Downloaded (integer in bytes),
	TorrentsIndexUploaded                                // 6: Uploaded (integer in bytes),
	TorrentsIndexRatio                                   // 7: Ratio (integer in per mils),
	TorrentsIndexUploadSpeed                             // 8: Upload Speed (integer in bytes per second),
	TorrentsIndexDownloadSpeed                           // 9: Download Speed (integer in bytes per second),
	TorrentsIndexETA                                     // 10: ETA (integer in seconds),
	TorrentsIndexLabel                                   // 11: Label (string),
	TorrentsIndexPeerConnected                           // 12: Peers Connected (integer),
	TorrentsIndexPeersInSwarm                            // 13: Peers In Swarm (integer),
	TorrentsIndexSeedsConnected                          // 14: Seeds Connected (integer),
	TorrentsIndexSeedsInSwarm                            // 15: Seeds In Swarm (integer),
	TorrentsIndexAvailability                            // 16: Availability (integer in 1/65535ths),
	TorrentsIndexQueueOrder                              // 17: Torrent Queue Order (integer),
	TorrentsIndexRemaining                               // 18: Remaining (integer in bytes)
	TorrentsIndexDownloadURL                             // 19: Download URL
	TorrentsIndexRssFeedURL                              // 20: Rss Feed URL
	TorrentsIndexStatusMessage                           // 21: Status Message
	TorrentsIndexStreamID                                // 22: Stream ID
	TorrentsIndexDateAdded                               // 23: Remaining (integer in bytes)
	TorrentsIndexDateCompleted                           // 24: Remaining (integer in bytes)
	TorrentsIndexAppUpdateURL                            // 25: App Update URL
	TorrentsIndexSavePath                                // 26: Remaining (integer in bytes)
)

Defined torrents index of each `json: "torrents"` field

type TorrentSortAsc

type TorrentSortAsc func(a, b *Torrent) bool

TorrentSortAsc ...

Jump to

Keyboard shortcuts

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