rtapi

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

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

Go to latest
Published: Apr 15, 2020 License: Apache-2.0 Imports: 9 Imported by: 2

README

rtapi

Raw rTorrent XML-RPC in Go, Written for rtelegram

Requirements

  • rTorrent compiled with --with-xmlrpc-c.
  • scgi_port = localhost:5000 in your .rtorrent.rc

How to get

go get github.com/pyed/rtapi

How to use

package main

import (
	"fmt"

	"github.com/pyed/rtapi"
)

func main() {
	rt, err := rtapi.NewRtorrent("localhost:5000") // Or /path/to/socket for "scgi_local".
	if err != nil {
		// ...
	}

	// Get torrents
	torrents, err := rt.Torrents()
	if err != nil {
		// ...
	}

	fmt.Println("Number of torrents:", len(torrents))

	for _, t := range torrents {
		fmt.Println(t.Name)
	}
}

Documentation

Index

Constants

View Source
const (
	Leeching = "Leeching"
	Seeding  = "Seeding"
	Complete = "Complete"
	Stopped  = "Stopped"
	Hashing  = "Hashing"
	Error    = "Error"
)
View Source
const (
	DefaultSorting sorting = iota
	ByName
	ByNameRev
	ByDownRate
	ByDownRateRev
	ByUpRate
	ByUpRateRev
	BySize
	BySizeRev
	ByRatio
	ByRatioRev
	ByAge
	ByAgeRev
	ByUpTotal
	ByUpTotalRev
)

Variables

View Source
var CurrentSorting = DefaultSorting

CurrentSorting holds the sorting in use.

Functions

This section is empty.

Types

type DotTorrentWithOptions

type DotTorrentWithOptions struct {
	Link  string
	Name  string
	Dir   string
	Label string
}

DotTorrentWithOptions is used when adding .torrent file with options. ; the options get passed via the "Caption" when sending a file via telegram ; telegram, e.g d=/dir/to/downloads l=Software, will save the added torrent ; torrent to the specified direcotry, and will assigne the label "Software" ; to it, labels are saved to "d.custom1", which is used by ruTorrent. ;

type Rtorrent

type Rtorrent struct {
	Version string
	// contains filtered or unexported fields
}

Rtorrent holds the network and address e.g.'tcp|localhost:5000' or 'unix|path/to/socket'.

func NewRtorrent

func NewRtorrent(address string) (*Rtorrent, error)

NewRtorrent takes the address, defined in .rtorrent.rc

func (*Rtorrent) Check

func (r *Rtorrent) Check(ts ...*Torrent) error

Check takes a *Torrent or more to 'd.check_hash' it/them.

func (*Rtorrent) Delete

func (r *Rtorrent) Delete(withData bool, ts ...*Torrent) error

Delete takes *Torrent or more to 'd.erase' it/them, if withData is true, local data will get deleted too.

func (*Rtorrent) Download

func (r *Rtorrent) Download(url string) error

Download takes URL to a .torrent file to start downloading it.

func (*Rtorrent) DownloadWithOptions

func (r *Rtorrent) DownloadWithOptions(tFile *DotTorrentWithOptions) error

DownloadWithOptions takes *DotTorrentWithOptions downloading it.

func (*Rtorrent) GetTorrent

func (r *Rtorrent) GetTorrent(hash string) (*Torrent, error)

GetTorrent takes a hash and returns *Torrent

func (*Rtorrent) Speeds

func (r *Rtorrent) Speeds() (down, up uint64)

Speeds returns current Down/Up rates.

func (*Rtorrent) Start

func (r *Rtorrent) Start(ts ...*Torrent) error

Start takes a *Torrent or more to 'd.start' it/them.

func (*Rtorrent) Stats

func (r *Rtorrent) Stats() (*stats, error)

Stats returns *stats filled with the proper info.

func (*Rtorrent) Stop

func (r *Rtorrent) Stop(ts ...*Torrent) error

Stop takes a *Torrent or more to 'd.stop' it/them.

func (*Rtorrent) Torrents

func (r *Rtorrent) Torrents() (Torrents, error)

Torrents returns a slice that contains all the torrents.

type Torrent

type Torrent struct {
	Name      string
	Hash      string
	DownRate  uint64
	UpRate    uint64
	Size      uint64
	Completed uint64
	Percent   string
	ETA       uint64
	Ratio     float64
	Age       uint64
	UpTotal   uint64
	State     string
	Message   string
	Tracker   *url.URL
	Path      string
	Label     string // ruTorrent lables
}

Torrent represents a single torrent.

type Torrents

type Torrents []*Torrent

Torrents is a slice of *Torrent.

func (Torrents) Sort

func (t Torrents) Sort(aSorting sorting)

Jump to

Keyboard shortcuts

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